Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Dates and Times in Python Where on Earth do Timezones Make Sense? Datetime Awareness

Why do I get an error "`paris` isn't a datetime." ? https://pastebin.com/akUjqjnV

This variable should be <class 'datetime.timezone'> and not datetime. If I run my code in python IDLE I get the correct output = 2015-10-21 13:29:00+01:00

import datetime

naive = datetime.datetime(2015, 10, 21, 4, 29)
pacific = datetime.timezone(datetime.timedelta(hours=-8))
hill_valley = datetime.datetime(2015, 10, 21, 4, 29,tzinfo = pacific)

paris = datetime.timezone(datetime.timedelta(hours=1))


2 Answers

Steven Parker
Steven Parker
216,810 Points

The instructions say "Make a new timezone that is UTC+01:00.", but they don't say that it must be stored in a variable or what to name it.

Then they say "Create a new variable named paris that uses your new timezone and the astimezone method to change hill_valley to the new timezone." So "paris" is expected to be a "datetime", as "hill_valley" is, but with a different timezone.

So while you've done all the steps, the final result doesn't get get assigned to "paris".

Thank you very much, Steven.