MySQL from_unixtime() 和 Python time.ctime() 不一致
我有一些使用 unixtime
的数据。我正在使用 Python 和 MySQL。
我注意到 MySQL GUI 工具函数 from_unixtime()
不等于 Python 的 time.ctime()
输出,甚至不等于 MySQL 命令行界面...
MySQL Command行:
#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 不能显示正确的数据,那么它还有什么意义呢?
谢谢,
中号
I have some data that uses unixtime
. I'm using Python and MySQL.
I have noticed that the MySQL GUI Tools function from_unixtime()
doesn't equal Python's output of time.ctime()
or even the MySQL cmd line interface...
MySQL Command Line:
#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 Tools:
# 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'
Can someone please shed some light on the discrepancies? What's the point of having a GUI if it doesn't show the correct data.
Thanks,
M
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两种情况下的时区都不同。只需在 MySQL GUI 工具中修复时区即可。
The time zone is different in both the cases. Just fix the time-zone in MySQL GUI tools and you're good to go.