I'm struggling here a bit with the time zone in MySQL.
What I need to do is to compare two time values in the database - both with different time zone to see if the specific event has already happened. I would like to do it inside of the sql statement - any idea if it's possible - and if so - if you could provide an example of the sql statemen开发者_C百科t please.
Don't store dates and times for a particular timezone. Store the dates/times in UTC, compare those, and then convert the result (if there is one) to the timezone you would like to display it in.
The examples for DateTime::setTimeZone() should point you in the right direction for doing conversions.
http://www.php.net/manual/en/datetime.settimezone.php
See more about UTC: http://en.wikipedia.org/wiki/UTC
精彩评论