Welcome to Linux Screw! If you're new here, you may want to subscribe our RSS feed.
I found using of Unix time to be very useful in various shell scripts and here are two simple commands to convert Unix/Linux date command to Unix time format and back to regular formating:
To convert Unix time to simple (regular) time please use:
date -u --date="1970-01-01 1187769064 sec GMT"
where 1187769064 is input Unix time. The output will be: Wed Aug 22 07:51:04 UTC 2007
To get Unix time seconds from regular one format just use:
date --date="Wed Aug 22 07:51:04 UTC 2007" +%s
where Wed Aug 22 07:51:04 UTC 2007 is input regular time. The output will be: 1187769064.
Update: another way to convert Unix time into regular date is to use the following command date -d @1187769064 (thanks to Mattias Lindvall), that is tested in Ubuntu and Fedora.

or do this
date -d @1187769064
Thanks Mattias! It works
date -d @1187769064 doesn't do it for me. I get "invalid date" running on Debian Sarge.
date -u --date="1970-01-01 1187769064 sec GMT" works fine.
Hi Magnus,
Hm… I've tested
date -d @1187769064in Ubuntu and Fedora without errors… I've got errordate: invalid dateonly after I've tried more than 11 digits (11877690644 instead of 1187769064). Please check input one more timeThanks for comment!
Completely useful tips that saved me from unneeded scripting on numerous occasions
Hi Ivan Arsenijevic,
Thanks for you comment!
Great tips, thanks.
FDF
Thanks. Solved my problem. On slackware, date -u --date="…. works, not date -d @…
anyone care to take a crack at it for the Mac OSX? (i.e., the above commands all do not work on the Mac).