In standard python, I can convert a string representation of time into datetime doing this:
date_string = u'Tue, 13 Sep 2011 02:38:59 GMT';
date_object = datetime.strptime(date_string, '%a, %d %b %Y %H:%M:%S %Z');
This works fine until I invoke the same over app engine where I get the error:
time data did not match format: data=2011-09-13 02:38:59 fmt=%a, %d %b %Y %H:%M:%S %Z
How would I convert this date string correctly so I can get a datetime representation?
Your error message indicates that you’re not really passing
Tue, 13 Sep 2011 02:38:59 GMT, but2011-09-13 02:38:59. Are you sure you pass the correct parameters tostrptime?My python works just fine for the following:
This also works fine for me: