I am trying to format a Datetime object I received from an XmlRPC API. The date is formatted like this (u'20121106T10:23:24'). I tried doing this:
s = datetime.strptime(u'20121106T10:23:24', "%Y%m%dT%H:%M:%S")
usedate = s.strftime('%Y-%m-%d')
I get this exception:
time data "DateTime '20121106T10:23:24' at b556886c" does not match format '%Y%m%dT%H:%M:%S'
I want the string to be in a YYYY-MM-DD format. Any help would be greatly appreciated. Thanks guys.
EDIT: Sharing exact error:
ValueError at /idea/
time data "DateTime '20121106T10:23:24' at b556886c" does not match format '%Y%m%dT%H:%M:%S'
Exception Type: ValueError
Exception Value:
time data "DateTime '20121106T10:23:24' at b556886c" does not match format '%Y%m%dT%H:%M:%S'
Dumb mistake on my part. I was calling repr instead of str and the methods didn’t return the same thing. I was under the impression a datetime repr would equal the str.