I have received three different unixtimes
lastSeen = 1416248381
firstSeen = 1416248157
and the last one is lastSeen - firstSeen:
duration = 224
Now, I can convert lastSeen and firstSeen into a datetime no problem. But I am having trouble with the duration.
I am unsure how to convert the duration into something like minutes/seconds. Does anyone have any idea if this can be done?
You need to convert your seconds to Hours&Minutes and you can do it using datetime
import datetime
lastSeen = 1416248381
firstSeen = 1416248157
duration = lastSeen - firstSeen
str(datetime.timedelta(seconds=duration))
The ouput will be: '0:03:44'
Without the str()
function you'll have: datetime.timedelta(0, 224)
Using time
import time
time.strftime("%H:%M:%S", time.gmtime(duration))
The ouput will be: '0:03:44'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With