4
votes

I'm confused about timezone differences when converting a MySQL datetime to Unix timestamp. It appears to me that MySQL datetimes (2011-02-07 09:45:00) are in the server's local timezone. I want to convert this datetime into a Unix timestamp, which is always in the GMT timezone. To do this conversion, PHP passes the datetime into strtotime. The datetime string contains no timezone, so will strtotime assume the argument is local timezone or GMT?

2

2 Answers

5
votes

The strtotime function will assume the datetime is in the server's local timezone.

1
votes

Why not use MySQL's UNIX_TIMESTAMP() function?