Marko Zadravec Marko Zadravec - 5 months ago 50
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")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download