Tuesday, June 14, 2011

Convert time to unix timestamp and vice versa

To convert current time to unix timestamp

$ date +%s
where %s is seconds since 1970-01-01 00:00:00 UTC

To convert a unix timestamp to a readable time/date
$ date -d @1308021863
Mon Jun 13 22:24:23 CDT 2011
where -d is for displaying time described by the string after @

No comments: