Convert mysql DATETIME column to epoch seconds

David542 picture David542 · May 31, 2012 · Viewed 42.2k times · Source

I have a column mysql datetime that is in DATETIME format.

Is there a way to SELECT this column in epoch seconds? If not, what would be the best way of converting the datetime format to epoch seconds? What type of field would be the best to capture this?

Answer

John Conde picture John Conde · May 31, 2012

Use MySQL's UNIX_TIMESTAMP function