convert mysql timestamp to mktime

mktime, mysql, php, timestamp

Solution

There is a MySQL function `unix_timestamp`. In your SQL query, instead of selecting the Datetime or Timestamp column directly, do this:

SELECT unix_timestamp(MyDatetimeColumn) FROM MyTable

Alternatively, if you have the string already, you could use the PHP function `strtotime()`.

Problem

I have the following MySQL timestamp: 2009-06-23 16:21:48 How can I convert it to a format like mktime()?

Original source