I want to parse a POST parameter like 2012-10-12T16:55+0300 to a datetime type in order to store it in ndb.DateTimeProperty() of my model.
Thus, what I have is:
from datetime import datetime
.....
my_date = datetime.strptime(self.request.get('my_date'), '%Y-%m-%dT%H:%M%z')
This call generates the following error:
ERROR 2012-10-12 14:03:08,376 webapp2.py:1553] ‘z’ is a bad directive in format ‘%Y-%m-%dT%H:%M%z’
Any ideas on how to solve this problem? I have read various posts but none of them helped me on this.
Thanks a lot in advance!
It seems someone filed a bug for the issue you see, which was rejected (see here). In short, %z is not always supported. Quoting from the bug report: