开发者

How does mySQL determine the time zone for the TIMESTAMP field?

According to mysqltutorial

The values of the MySQL TIMESTAMP columns depend on connection’s time zone. When insert values for MySQL TIMESTAMP columns, they are converted to Universal Coordinated Time (UTC) from connection’s time zone. When you select the value, the server converts it back from UTC t开发者_Python百科o the connection’s time zone so you have the same value that you inserted.

Where does it get this info. from, the time the user sets his OS to or from some other method?

Javascript also has a way to do timezones but is more involved: onlineaspect


To specify connection-specific time you need to perform

SET time_zone = TZ;

Where TZ can be either numerical offset like +11:00 or name of timezone Asia/Vladivostok (for the latter you need to import timezones description. Ask your DBA to do so)


the example there is wrong, i just tested it. it returns the previously inserted timestamp, regardless of the timezone. mysql will always insert the time you specify, without modifying it. if you need timezone adjustment, you have to tell mysql explicit to do so; otherwise all times are assumed to be "local server time".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜