Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

starter is a naive datetime. Use pytz to make it a "US/Pacific" datetime instead and assign this converted datetime to the variable local.

import datetime
import pytz

pacific = pytz.timezone('US/Pacific')
fmt = '%m-%d %H:%M %Z%z'
utc = pytz.utc
start = pacific.localize(datetime.datetime(2015, 10, 21, 4, 29))
start_pacific = start.astimezone(pacific)
starter = datetime.datetime(2015, 10, 21, 4, 29)
starter_utc = datetime.datetime(2015, 10, 21, 4, 29, tzinfo=utc)
local = starter_utc.astimezone(pacific)
Source by teamtreehouse.com #
 
PREVIOUS NEXT
Tagged: #starter #naive #Use #pytz #datetime #assign #converted #datetime #variable
ADD COMMENT
Topic
Name
2+7 =