Possible duplicate:
How to parse ISO formatting date in python?
I have an isotformat datetime as a string, as in the example below -
'2011-05-31T04:35:33.127-05:00'
What is the best way to convert it to a python datetime object? I came across some posts that tell how to get the isoformat string, but not vice versa.
Thanks!!
Edit based on Jan's comment -
>>>import dateutil.parser >>> d1='2011-05-31T04:35:33.127-05:00' >>> d2=dateutil.parser.parse(d1) >>> d2 datetime.datetime(2011, 5, 31, 4, 35, 33, 127000, tzinfo=tzoffset(None, -18000))
I need to get a datetime object for the local time represented by the source string. Since I do not know in what time zone the input date was entered, I can not use the astimezon method. What would be the best way to get this? Thanks!!
Rinks source share