I have a utc timestamp in the IS8601 format and am trying to convert it to unix time. This is my console session:
In [9]: mydate Out[9]: \'2009-07-17T01:21:0
naive_utc_dt = parseddate.replace(tzinfo=None) timestamp = (naive_utc_dt - datetime(1970, 1, 1)).total_seconds() # -> 1247793660.0
See more details in another answer to similar question.
And back:
utc_dt = datetime.utcfromtimestamp(timestamp) # -> datetime.datetime(2009, 7, 17, 1, 21)