使用 DBeaver,我们尝试执行以下查询。
UPDATE listing SET ScheduledTime='2019-01-09 15:14:51.0', Status='SCHEDULED' where ID=108
执行成功后,我们可以在DB中看到ScheduledTime列为“2019-01-09 20:44:51”。为什么会出现时间不匹配的情况以及如何解决?非常感谢您在此事上提供的帮助。
最佳答案
您在存储和查看数据时使用不同的时区设置。作为 mysql 文档 timestamp说:
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.) By default, the current time zone for each connection is the server's time. The time zone can be set on a per-connection basis.
Mysql文档介绍了如何查看和设置时区here
关于MySQL时间戳类型数据插入问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54086358/