1# here are a few ways to convert time zone
2from datetime import datetime
3from dateutil import tz
4
5# METHOD 1: Hardcode zones:
6from_zone = tz.gettz('UTC')
7to_zone = tz.gettz('America/New_York')
8
9# METHOD 2: Auto-detect zones:
10from_zone = tz.tzutc()
11to_zone = tz.tzlocal()
12
13# utc = datetime.utcnow()
14utc = datetime.strptime('2011-01-21 02:37:21', '%Y-%m-%d %H:%M:%S')
15
16# Tell the datetime object that it's in UTC time zone since
17# datetime objects are 'naive' by default
18utc = utc.replace(tzinfo=from_zone)
19
20# Convert time zone
21central = utc.astimezone(to_zone)
22