我有两个这样的时间戳:它们的格式为:YYYYmmddHHMMSSfraction
t1=20131229135931664000
t2=20131229140021638000
如何以秒为单位找到时间戳的差异?
解析datetime.datetime.strptime()
:
import datetime
format = '%Y%m%d%H%M%S%f'
dt1 = datetime.datetime.strptime(str(t1), format)
dt2 = datetime.datetime.strptime(str(t2), format)
difference = (dt2 - dt1).total_seconds()