I need to convert seconds to HH:MM:SS format without failing if hour greater than 24hrs.
Such as 04:32:18 or 26:23:37
Here's what I tried:
import time
cd = time.time()
while True:
# Count seconds
te = int(time.time()-cd, 0)
# Print the secs
print('Time elapsed:', te, 'secs')
time.sleep(1)
This code prints this result:
Time elapsed 1.0 secs
Time elapsed 2.0 secs
...
But I want this result:
Time elapsed 00:00:01 secs
Time elapsed 00:00:02 secs
...
And if the hour greater than 24, the program must run and print something like:
Time elapsed: 28:34:35
Time elapsed: 28:34:36
...
Hope you help.