开发者

MySQL time zone comparison

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜