Mysql FROM_UNIXTIME作为UTC [英] Mysql FROM_UNIXTIME as UTC
本文介绍了Mysql FROM_UNIXTIME作为UTC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何获得
FROM_UNIXTIME
在mysql中是UTC/GMT吗?该日期将在连接的时区中返回.
as UTC/GMT in mysql? The date is returned in the timezone of the connection.
我不想更改连接的时区.
I don't want to change the timezone of the connection.
推荐答案
最好提前设置时区:
SET time_zone='UTC';
select FROM_UNIXTIME(1277942400);
原因是涉及本地时区的转换可能会造成损失. 此处的文档(请参见UNIX_TIMESTAMP()
部分下的第4段,以注:"开头)
The reason is that conversions involving a local time zone can be lossy. There is an example of this in the docs here (see the 4th paragraph under the UNIX_TIMESTAMP()
section starting with "Note:")
这篇关于Mysql FROM_UNIXTIME作为UTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文