gpt4 book ai didi

mysql - 如何插入 YYYY-MM-DDThh :mm:ss±hh:mm date in mysql with timezone?

转载 作者:行者123 更新时间:2023-11-29 06:23:22 24 4
gpt4 key购买 nike

我尝试在时间戳字段中插入此日期“2014-06-18T12:32:56.575+10:00”。但是没有时区保存“2014-06-18 12:32:56”。如何将日期转换为 UTC 或其他时区?

最佳答案

使用datetime 数据类型代替timestamp

根据 MySQL 文档:

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

如果您已经在使用 datetime,则设置 MySQL 的默认时区或为每个连接设置时区。

关于mysql - 如何插入 YYYY-MM-DDThh :mm:ss±hh:mm date in mysql with timezone?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32341600/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com