码迷,mamicode.com
首页 > 其他好文 > 详细

计算时间差

时间:2019-01-04 12:21:39      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:alt   计算   highlight   mtime   ptime   cal   mon   str   oca   

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))

  

计算时间差

标签:alt   计算   highlight   mtime   ptime   cal   mon   str   oca   

原文地址:https://www.cnblogs.com/selid/p/10218381.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!