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_event.start_time < current_time < my_event.end_time
Your answer is the way to go as long as start_time and end_time don't have an associated tzinfo class. You can't directly compare a naive datetime with a timezoned-datetime.
you can use a simple if comparing three dates, like this
if date1 < yourdate < date2:
...do something...
else:
...do ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With