1. 程式人生 > >計算時間差

計算時間差

div mtime n-1 log ptime pre pri 時間 計算

1 import time
2 true_time=time.mktime(time.strptime(2017-09-11 08:30:00,%Y-%m-%d %H:%M:%S))
3 time_now=time.mktime(time.strptime(2017-09-12 11:00:00,%Y-%m-%d %H:%M:%S))
4 dif_time=time_now-true_time
5 struct_time=time.gmtime(dif_time)
6 print(過去了%d年%d月%d天%d小時%d分鐘%d秒%(struct_time.tm_year-1970,struct_time.tm_mon-1,
7 struct_time.tm_mday-1,struct_time.tm_hour, 8 struct_time.tm_min,struct_time.tm_sec))

計算時間差