Answer the question
In order to leave comments, you need to log in
How to correctly calculate the time difference?
Good afternoon, I wrote the following function:
def check_difference_time(start, end):
FMT = '%H:%M'
tdelta = datetime.strptime(end, FMT) - datetime.strptime(start, FMT)
return tdelta >= timedelta(hours=1, minutes=30)
Answer the question
In order to leave comments, you need to log in
I don't know about beautiful, but here's what I managed to achieve
from datetime import datetime
FMT = '%H:%M'
print((datetime.strptime("01:30", FMT) - datetime.strptime("22:00", FMT)).seconds) # => 12600 - это правильно
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question