I'm using the default python datetime string format with a JSON webservice.
Then, I'm trying to compare it with an actual datetime. And I'm also using timezone with pytz.utc
.
Here is my string date:
print date
2013-02-26 21:28:37.261134+01:00
Trying to convert my string into a datetime (edit for timezone with pytz
):
if datetime.strptime(date, '%Y-%m-%d %H:%M:%S.%f+%Z') < datetime.now(pytz.utc):
Unfortunately, it doesn't work.
ValueError: time data '2013-02-26 21:28:37.261134+01:00' does not match format '%Y-%m-%d %H:%M:%S.%f%Z'
Can anyone tell me the correct syntax for the strptime
format, to use my date ?