my_event = Event.objects.get(id=4)
current_time = datetime.datetime.now()
How do I do check if my current time is between them?
my_eve
I know old, but since this is so high on Google results, answers here don't take into consideration two cases:
I wrote a function to take care of time comparison, hope this helps anyone viewing this old question.
def process_time(intime, start, end):
if start <= intime <= end:
return True
elif start > end:
end_day = time(hour=23, minute=59, second=59, microsecond=999999)
if start <= intime <= end_day:
return True
elif intime <= end:
return True
return False