How to convert MySQL time to UNIX timestamp using PHP?

daGrevis picture daGrevis · Jan 2, 2011 · Viewed 115.8k times · Source

There are a lot of questions that ask about 'UNIX timestamp to MySQL time'. I needed the reversed way, yea... Any idea?

Answer

UltraInstinct picture UltraInstinct · Jan 2, 2011

Use strtotime(..):

$timestamp = strtotime($mysqltime);
echo date("Y-m-d H:i:s", $timestamp);

Also check this out (to do it in MySQL way.)

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp