I need check if a timestamp string is into a time range:
tt = '26-12-2012 18:32:51'
t1 = datetime.timedelta(0, 28800) #08:00 hrs
t2 = datetime.timedelta(0, 68400) #19:00 hrs
To compare do I need convert the timestamp into a timedelta?, how can I do that, to compare like:
if tt >= t1 and tt <= t2:
Thanks..
First, construct a datetime object with
datetime.strptime:Now, construct a second datetime object which only represents the date portion:
From that you can get a
datetime.timedeltasuitable for comparing with your othertimedeltas: