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? Timezonapalooza

NameError: name 'timezone' is not defined. Please explain why?

from datetime import datetime import pytz

pytz.all_timezones

other_timezones = [ pytz.timezone("US/Eastern"), pytz.timezone("Pacific/Auckland"), pytz.timezone("Asia/Calcutta"), pytz.timezone("UTC"), pytz.timezone("Europe/Bucharest"), pytz.timezone("Europe/Paris"), pytz.timezone("Europe/London"), pytz.timezone("Europe/Madrid"), pytz.timezone("Europe/Moscow"), pytz.timezone("Europe/Stockholm") ]

fmt = "%Y-%m-%d %H:%M:%S %Z%z"

while True: date_input = input("When is your meeting? Please use MM/DD/YYYY HH:MM format. ") try: local_date = datetime.strptime(date_input, "%m/%d/%Y %H:%M") except ValueError: print ("{} doesn't seems to be correct format. Please try again" .format(date_input)) else: local_date = pytz.timezone("Europe/Kiev").localize(local_date) utc_date = local_date.astimezone(pytz.utc)

    output = []
    for i in other_timezones:
        output.append(utc_date.astimezone(timezone))
    for y in output:
        print(y.strftime(fmt))
    break

Issue solved. i instead of timezone

my stupid fault

1 Answer

Issue solved. i instead of timezone

my stupid fault