I am trying to find the difference between two times in Python. It is guaranteed that the times are on the same day.
#For example
s1 = '13:00'
s2 = '12:58'
The difference between these two times should be 2 mins. The output should be: 2
This is my code:
from datetime import datetime
s1 = '13:00'
s2 = '12:58'
FMT = '%H:%M'
tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
print(tdelta)
But it returns:
-1 day, 23:58:00
How can i fix this and return my time as: 2