I was wondering for a short way to do this:
Lets say I have 2 time since epoch: 1418647594
and 1418177737
; how would I get the difference of the 2 ? 之差? I know there are similar questions but they involve installing modules. This one is slightly different!
Thanks for the help.
tStart = 1418177737
tStop = 1418647594
tElapsed = tStop - tStart
diffSeconds = tElapsed / 1000 % 60
diffMinutes = tElapsed / (60 * 1000) % 60
diffHours = tElapsed / (60 * 60 * 1000) % 24
diffDays = tElapsed / (24 * 60 * 60 * 100)
you can use datetime:
>>> import datetime
>>> diff = datetime.datetime.fromtimestamp(1418647594) - datetime.datetime.fromtimestamp(1418177737)
>>> diff
datetime.timedelta(5, 37857)
>>> diff.days
5
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.