I want to calculate the difference between two timestamps in seconds, for example:
t1 = "12:59:54"
t2 = "01:00:14"
So the difference should be 20 seconds.
(Note that dates are strings in my case.)
And how would I know if t1 > t2
or vice-versa?
What I have tried so far:
t1 = datetime.strptime(t1, "%H:%M:%S")
t2 = datetime.strptime(t2, "%H:%M:%S")
if t1 > t2:
difference = t1 - t2
else:
difference = t2 - t1
print(difference.total_seconds())
This prints 43180, but it should be 20, right?