Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSUDHARSAN CHAKRAVARTHI
Courses Plus Student 2,434 Pointstimezone on starter variable
As my understanding, starter variable is assigned with the time which has a zone info associated [ UTC ] with it and localized.
All we need to do is convert it to UTC timezone using astimezone() method and convert it to any time zone.
Can you please confirm my understanding.
import datetime
import pytz
starter = pytz.utc.localize(datetime.datetime(2015, 10, 21, 23, 29))
2 Answers
MUZ140889 Dephine Chenayi Chihota
6,766 Pointshie Sudharsan. the first step is to create the function as the question says. inside the function you then use your pytz.timezone and astimezone to change starter to that timezone, like so
def to_timezone(tz):
starter_new = starter.astimezone(pytz.timezone(tz))
return starter_new
SUDHARSAN CHAKRAVARTHI
Courses Plus Student 2,434 PointsThank you very much. Later i too found the issue and solved.
pala
15,913 Pointspala
15,913 Pointsthank you so much!