unix time to human readable format

by prettyscripts on 2008-07-18 10:58:05

miscunix

some log files such as squid log uses uses unix time as timestamp, which looks like some random number generated number.

you can use this online conversion tool.

to run from unix command line, to convert to human readable format, eg in yyyy-mm-dd hh:mm:ss format,

Code:

echo <timestamp> | awk '{ print strftime("%Y-%m-%d %H:%M:%S", $1); }'

replace <timestamp> with the unix timestamp. the format for strftime is similar to php function with the same name.

i put this in a shell script so i don’t have to remember the awk command. if there’s a simpler way to do it, please post in comment.

Tags: timestamp, unix

No feedback yet

Leave a comment


Your email address will not be revealed on this site.
PoorExcellent
note: all comments are moderated. do not spam and do not advertise. only comments relevant to the post will be published.
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)