Okay, this is probably a very basic question; but, I’m just getting back in the saddle with Linux.
I have a variable that hold an Epoch time called pauseTime.
I need that variable to become human readable (something like 2012-06-13 13:48:30).
I know I can just type in
date -d @133986838 //just a random number there
and that will print something similar. But I need to get the variable to hold that human readable date, instead of the epoch time… I keep running into errors with everything I’m trying. Any thoughts on how I can do this?
Well do this:
and then
or in Bash do directly:
If you want formatting, say in the usual ISO format:
The formats behind the
+are explained inman date.Note:
$()is the modern form of the backticks. I.e. catching output from a command into a variable. However,$()makes some things easier, most notably escaping rules inside of it. So you should always prefer it over backticks if your shell understands it.