2011-02-08 65 views
1

我有一些數據使用unixtime。我正在使用Python和MySQL。MySQL from_unixtime()和Python time.ctime()不一致

我已經注意到了MySQL GUI工具功能from_unixtime()不等於Python的的time.ctime()輸出甚至MySQL的CMD線接口...

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的意義何在。

感謝,
中號

回答

1

的時區是在兩種情況下的不同。只需在MySQL GUI工具中修復時區,就可以開始了。