Tag Archives: datetime

Python Convert ISO8601/UTC to Local Time

Ok, I looked this up twice now… once too many

Suppose you have a datetime of the form “2010-05-08T23:41:54.000Z” and you want a local datetime object

import pytz, dateutil.parser
utctime = dateutil.parser.parse("2010-05-08T23:41:54.000Z")
localtime = utctime.astimezone(pytz.timezone("Canada/Eastern"))

Boom