How to convert a Unix timestamp to a readable date using command line tools.

Using Perl

1
2
TIMESTAMP=1173279767
perl -e "print scalar(localtime($TIMESTAMP))"

Using Perl with ctime module

1
2
TIMESTAMP=1173279767
perl -e "require 'ctime.pl'; print &ctime($TIMESTAMP);"

Using Shell with awk

1
echo 1173279767 | awk '{print strftime("%c",$1)}'

Using Shell with date

1
2
TIMESTAMP=1173279767
date -d "1970-01-01 $TIMESTAMP sec GMT"

Or even simpler:

1
date -d@1234567890

Last updated 11 Dec 2009, 21:38 +0200. history