I am trying to check if the current time is between a certain time period,in this case between 10:00pm to 11:00pm but running into below error,any guidance on how to fix this?
import datetime
current_time = datetime.datetime.now().time()
if '22:00' <= current_time <= '23:00':
print "current time is between 10:00pm to 11:00pm"
else:
print "current time is NOT between 10:00pm to 11:00pm"
Error:-
Traceback (most recent call last):
File "datetime_script.py", line 4, in <module>
if '22:00' <= current_time <= '23:00':
TypeError: can't compare datetime.time to str