计算时间差

rec2=time.mktime(time.strptime('2019.1.3 11:37:50','%Y.%m.%d %H:%M:%S'))
rec1=time.mktime(time.strptime('2018.1.2 19:37:50','%Y.%m.%d %H:%M:%S'))
rec=rec2-rec1
print(rec)
time.localtime(rec)
print(time.strftime('%H:%M:%S',time.gmtime(rec)))
s=time.gmtime(rec)
print('过去了%d年%d月%d日%d时%d分%d秒'%(s.tm_year-1970,s.tm_mon-1,s.tm_mday,s.tm_hour,s.tm_min,s.tm_sec))

  

posted on 2019-01-04 10:23  耳矝  阅读(82)  评论(0编辑  收藏  举报

导航