I have a table with a datetime column. Into this column I have written UTC dates using UTC_TIMESTAMP(). Now, from PHP, I want to get this UTC date as an unix timestamp. How?
I know of the UNIX_TIMESTAMP() function. I’m not sure it’s reliable since it uses local time zone and stuff. I just want a pure conversion from the UTC datetime to the number of seconds since 1970…
In PHP you’d use
strtotime().Edit:
UNIX_TIMESTAMPuses local time zones when converting data stored astimestampnot data stored asdatetime. See: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp and http://dev.mysql.com/doc/refman/5.5/en/datetime.html.As you’re using
datetime,UNIX_TIMESTAMPshould be safe.