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

Related posts:

  1. Python Debug with ipdb
  2. How to Convert Numpy Array to Tuple
  3. Python Challenge Level 14: Italy – Code
  4. Qt with C++ or Python Tutorial
  5. Determining Run-Time/DesignMode in .NET