Convert Unix timestamp into human-readable format on AIX

aixdatekshtimestamps

I need to convert unix timestamp (number of seconds since 1970, e.g. 1381260225 is Tue Oct 8 19:23:45 GMT 2013) into a standard human-readable format.

I could get some answers by googling but those were not a suitable solution for me because I don't use Linux, I use an AIX 6.1 machine with ksh88. AIX does not have GNU utilities.

Best Answer

If you were on Linux, you could simply use:

date -d @1381260225

Or you could use gawk:

echo "1381260225" | gawk '{print strftime("%c",$1)}'

Or Python:

python -c "import datetime; print  datetime.datetime.fromtimestamp(1381865497)"

Or Perl:

perl -e 'print(scalar(localtime(1381865497)), "\n";'

However none of these solutions are available on a stock AIX installation. All of these tools (GNU coreutils, GNU awk, Perl, Python) are available as separate packages as part of the AIX toolbox for Linux applications.