美文网首页
date and time

date and time

作者: BenjaminCool | 来源:发表于2019-01-07 11:43 被阅读5次
datetime and timestamp

https://dev.mysql.com/doc/refman/5.6/en/datetime.html

MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. (This does not occur for other types such as DATETIME.)

timestamp根据系统所在时区而定,系统时区更改了 stored timestamp类型的字段 content 也会发生改变。

datetime不会改变,在什么时区存的,系统切换到另外时区,不会改变的。

timestamp和datetime默认存储的都是当前时区的utc时间,注意是当前时区对应的utc时间。

CREATE TABLE t1 (
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

相关文章

网友评论

      本文标题:date and time

      本文链接:https://www.haomeiwen.com/subject/bkturqtx.html