I have two dates:
Sat Mar 15 19:47:17 +0000 2014
2014-03-12 19:50:22.159411+00:00
I need to compare these two dates but I get the error
TypeError: can't compare datetime.datetime to unicode
How should I convert one of them?
I have two dates:
Sat Mar 15 19:47:17 +0000 2014
2014-03-12 19:50:22.159411+00:00
I need to compare these two dates but I get the error
TypeError: can't compare datetime.datetime to unicode
How should I convert one of them?
The easiest method is to use the 3rd party dateutil
lib, and do:
from dateutil.parser import parse as parse_date
unicode_text = 'Sat Mar 15 19:47:17 +0000 2014'
dt = parse_date(unicode_text)
# 2014-03-15 19:47:17+00:00
if dt == other_datetime:
# do something