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?
Asked
Active
Viewed 4,920 times
4

JoJo
- 19,587
- 34
- 106
- 162
2 Answers
1
Why not use MySQL's UNIX_TIMESTAMP() function?

Jan
- 2,295
- 1
- 17
- 16
-
Because the project running on the server, and the sever are in two different timezones. Referring the servers timezone will give wrong data to the site user. I've used php's date_default_timezone_set('XXX'); to change the default timezone for the site. – Cassandra Feb 12 '15 at 01:07