Sqlite3数据实时转换为python
我从sqlite3读取数据,我需要使用“上次访问时间”,但数据是“1297908532292388L”,我只使用pythonSqlite3数据实时转换为python,python,sqlite,datetime,time,Python,Sqlite,Datetime,Time,我从sqlite3读取数据,我需要使用“上次访问时间”,但数据是“1297908532292388L”,我只使用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 p
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。。。。范围限制,所以我如何将其转换为实时,非常感谢
>>> from datetime import datetime
>>> datetime.utcfromtimestamp(1297908532.2912388)
datetime.datetime(2011, 2, 17, 2, 8, 52, 291239)
如果上次访问时间与2011-02-17相对应,则您可以使用
>>> from datetime import datetime
>>> datetime.utcfromtimestamp(last_visit_time / 1e7)
datetime.datetime(2011, 2, 17, 2, 8, 52, 291239)
但是我不知道最后一次访问的时间,所以可以在没有其他信息的情况下从12979085330693664L中提取时间吗?如果你没有进一步的信息,你必须猜测。但我不认为还有很多其他的选择。数据库中有更多的时间戳信息吗?如果使用我的方法转换其他时间戳,会得到逻辑结果吗?例如,没有比网站年龄大几倍,没有比现在新几倍,等等。12979231706879288L最新的时间戳,刚才,然后12979231436918790L可能两分钟前,但我不能做客…帮帮我