I'm struggling to convert ISO 8601 datetime coming from angular datetime component on the client side in the python backend. The date is coming from the angular-material-datetimepicker library in this format: '2016-10-24T10:00:00.000Z'
. How do I convert to a datetime object to send to the datastore? I'm using Google App Engine. Here's what I've tried fiddling with in pycharm among other things I've found on other forums;
works
>>> datetime.datetime.strptime('2016-10-24T10:00:00Z', '%Y-%m-%dT%H:%M:%SZ')
datetime.datetime(2016, 10, 24, 10, 0)
does not work
datetime.datetime.strptime('2016-10-24T10:00:00.000Z', '%Y-%m-%dT%H:%M:%SZ')
As seen above, the first command with the 'nanoseconds i think?' does not work. That is the actual format angular sends through. When I remove .000
it works as seen in the second command. What method call should I execute on the first date for it to work? Also I tried;
>>> datetime.datetime.strptime('2016-10-24T10:00:00.000Z', '%Y-%m-%dT%H:%M:%S%fZ')