I have a string like "2020-01-20T11:00:05-05:00"
, and I want to compare this with datetime.now()
to see if it is greater than it.
I think I need to use datetime.strptime(..., ...)
although I don't know what to do about the timezone bit.
How can I solve this?
Thanks.
EDIT: date_time = datetime.strptime("2020-01-20T11:00:05-05:00", "%Y-%m-%dT%H:%M:%S%z")
. This works, however now when I compare them I get TypeError: can't compare offset-naive and offset-aware datetimes
.
EDIT2: Perhaps I need to make my datetime.now()
timezone aware?