I would like to calculate the time difference between two 24-hour time values, containing only the hour, minute, and second values. Then, I would like to split up the time difference into the hour, minute, and seconds values, and output them as three different variables.
For example, my desired output would be:
time1 = '10:33:26'
time2 = '17:25:39'
Hours: 6
Minutes: 52
Seconds: 13
Because 17:25:39 is 6 hours, 52 minutes, and 13 seconds after 10:33:26.
I have tried the following code:
from datetime import datetime
s1 = '10:33:26'
s2 = '17:25:39'
FMT = '%H:%M:%S'
tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
print(tdelta)
It correctly outputs 6:52:13
, but I don't know how to split up the 6
, 52
, and 13
into three different variables.