#Check if now is before or after 8am: now = datetime.datetime.now() today8am = now.replace(hour=8, minute=0, second=0, microsecond=0) #Perform the checks: if (now < today8am): ... if (now == today8am): ...
Here is what the above code is Doing:
1. We're creating a datetime object for the current time.
2. We're creating a datetime object for 8am today.
3. We're comparing the two datetime objects.