【问题标题】:MySQL from_unixtime() and Python time.ctime() not agreeingMySQL from_unixtime() 和 Python time.ctime() 不一致
【发布时间】:2011-02-08 17:29:25
【问题描述】:

我有一些使用unixtime 的数据。我正在使用 Python 和 MySQL。

我注意到 MySQL GUI 工具函数 from_unixtime() 不等于 Python 的输出 time.ctime() 甚至 MySQL 命令行界面...

MySQL 命令行:

#This returns the correct time

mysql> select from_unixtime(1295147016.45300);
+---------------------------------+
| from_unixtime(1295147016.45300) |
+---------------------------------+
| 2011-01-15 21:03:36             |
+---------------------------------+
1 row in set (0.05 sec)

MySQL GUI 工具:

# Incorrect Time!

select from_unixtime(1295147016.45300);

2011-01-16 03:03:36 

Python:

#This returns the correct time

>>> import time
>>> time.ctime(1295147016.45300)
'Sat Jan 15 21:03:36 2011'

有人可以解释一下这些差异吗?如果 GUI 不能显示正确的数据,那么它还有什么意义呢。

谢谢,
M

【问题讨论】:

    标签: python mysql time unix-timestamp


    【解决方案1】:

    这两种情况的时区不同。只需在 MySQL GUI 工具中修复时区即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-19
      • 2018-03-17
      • 2019-05-11
      • 1970-01-01
      • 2012-12-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多