开发者

Converting timestamp to datetime in MYSQL

Do you lose any data when convertin开发者_运维知识库g a timestamp to datetime in mysql? Also what are the major differences between the two?


From the docs (TIMESTAMP Propeties):

TIMESTAMP values are converted from the current time zone to UTC for storage, and converted back from UTC to the current time zone for retrieval. (This occurs only for the TIMESTAMP data type, not for other types such as DATETIME.) By default, the current time zone for each connection is the server's time.

[...]

If you store a TIMESTAMP value, and then change the time zone and retrieve the value, the retrieved value is different from the value you stored. This occurs because the same time zone was not used for conversion in both directions.


You can create an extra column and a query to copy your data into that column before you venture the conversion.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜