Marko Zadravec Marko Zadravec - 21 days ago 8
JSON Question

Parse date from json in Django

I try to parse date field inside JSON object:

"year": 1,
"name": "marko",
"date": "2015-10-1 3:00 PM GMT+1:00"

I try to something like: = datetime.datetime.strptime(dictionary.get('date'), '%Y-%m-%d %I:%M ')

but I get error...

I know that %d should be a zero based like:


but I get 1 in JSON.

Answer Source

try using dateutil

from dateutil.parser import parse
parse("2015-10-1 3:00 PM GMT+1:00")