Jan 1st 1970! Unix time conversions

If you store dates in MySQL in unix time format, its nice to be able to quickly convert it back!

In Linux, the terminal command can either be:

$ date -d @1344262406
Mon Aug  6 15:13:26 BST 2012


$ date -u --date="1970-01-01 1344262406 sec GMT"
Mon Aug  6 14:13:26 UTC 2012

Guess which one I prefer? Note the timezone differences.

On a Mac (or any other Unix), you can try this:

$ date -r 1282368345
Sat Aug 21 07:25:45 CEST 2010
$ date -r 1282368345 +%Y-%m-%d

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s