gpt4 book ai didi

MySQL unixtime 序列

转载 作者:太空宇宙 更新时间:2023-11-03 11:16:49 26 4
gpt4 key购买 nike

unixtimestamp 值不是线性的?在以下示例中,我期望 599 日期值小于第二个 600 值。

mysql> select from_unixtime(1289109599);
+---------------------------+
| from_unixtime(1289109599) |
+---------------------------+
| 2010-11-07 01:59:59 |
+---------------------------+
1 row in set (0.00 sec)

mysql> select from_unixtime(1289109600);
+---------------------------+
| from_unixtime(1289109600) |
+---------------------------+
| 2010-11-07 01:00:00 |
+---------------------------+
1 row in set (0.00 sec)

mysql> select from_unixtime(1289109601);
+---------------------------+
| from_unixtime(1289109601) |
+---------------------------+
| 2010-11-07 01:00:01 |
+---------------------------+
1 row in set (0.00 sec)

当我在其他服务器上尝试类似的命令时,我得到以下输出...

mysql> select from_unixtime(1289120399);
+---------------------------+
| from_unixtime(1289120399) |
+---------------------------+
| 2010-11-07 01:59:59 |
+---------------------------+
1 row in set (0.00 sec)

mysql> select from_unixtime(1289120400);
+---------------------------+
| from_unixtime(1289120400) |
+---------------------------+
| 2010-11-07 01:00:00 |
+---------------------------+
1 row in set (0.00 sec)

mysql> select from_unixtime(1289120401);
+---------------------------+
| from_unixtime(1289120401) |
+---------------------------+
| 2010-11-07 01:00:01 |
+---------------------------+
1 row in set (0.00 sec)

更新:由于夏令时,我得到了两个不同 unix 时间值的相同时间戳。有趣!

mysql> select from_unixtime(1289109600);
+---------------------------+
| from_unixtime(1289109600) |
+---------------------------+
| 2010-11-07 01:00:00 |
+---------------------------+
1 row in set (0.00 sec)

mysql> select from_unixtime(1289106000);
+---------------------------+
| from_unixtime(1289106000) |
+---------------------------+
| 2010-11-07 01:00:00 |
+---------------------------+
1 row in set (0.00 sec)

最佳答案

这是一个 DST问题。

您的 mySQL 服务器所在的时区 DST 于 2010 年 11 月 7 日 02:00 结束。时钟调回 01:00,因此出现差异。

manual 中更多关于 mySQL 的时区支持.

关于MySQL unixtime 序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4525909/

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