1

我从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....范围限制,所以我怎样才能将它翻译成实时,非常感谢!

4

1 回答 1

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)
于 2012-04-18T13:24:43.977 回答