我从sqlite3读取数据,我需要使用'last_visit_time',但数据是'12979085322912388L',我只是使用python
import datetime,time
Traceback (most recent call last):
File "t1.py", line 21, in <module>
print time.gmtime(long(12979085330693664L))
ValueError: timestamp out of range for platform time_t
....我不能使用ctime,gmtime ....范围限制,所以我怎么能把它翻译成实时,非常感谢!!
答案 0 :(得分:0)
>>> from datetime import datetime
>>> datetime.utcfromtimestamp(1297908532.2912388)
datetime.datetime(2011, 2, 17, 2, 8, 52, 291239)
如果last_visit_time
对应2011-02-17,那么您可以使用
>>> from datetime import datetime
>>> datetime.utcfromtimestamp(last_visit_time / 1e7)
datetime.datetime(2011, 2, 17, 2, 8, 52, 291239)