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? Actually, Use pytz Instead

Welby Obeng
Welby Obeng
20,340 Points

how come the teacher didnt localize naive time zone and instead converted an eastern timezone

Video duration : 6:45

Kenneth Love started with naive datetime, localize it to eastern then converted it to utc.

how come the teacher didn't localize naive time zone straight to eastern and instead converted an eastern timezone to utc time zone? didn't he get the eastern timezone from localizing naive?

2 Answers

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

For that, yeah, it's mostly illustrative. But in the real world, you'd, ideally, have a naive datetime that you know where it was created. You'd then localize it to that timezone, then convert to UTC (unless you're lucky enough to have created it in UTC to begin with).

for teaching purposes maybe?