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 trial

Python Dates and Times in Python (2014) Where on Earth do Timezones Make Sense? Timezone Strings

What Iยดm doing wrong? Any clue?

I used localize and timezone methods to convert starter into the correct timezone, but seems to be wrong and I can't see the error here.

Please help me :) Thanks!

timezone.py
import datetime

import pytz

starter = pytz.utc.localize(datetime.datetime(2015, 10, 21, 23, 29))
def to_timezone(tz):
  t = pytz.timezone(tz).localize(starter)
  return t

1 Answer

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

Try something like this:

import datetime

import pytz

def to_timezone(tz): Zim = pytz.timezone(tz) new_time = starter.astimezone(Zim) return new_time

Thanks!!!