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? pytz Format

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

Can you provide an example a formated local string for this pytz format challenge?

From the Datess and Times in Python / Where on earth do timezones make sense / pytz format challenge, the wanted format appears to be:

>>> str(local)
'2015-10-21 04:29:00-07:00'

But the closest format string I can find does not provide the colon in the time zone, Bummer!

>>>fmt3 = "%Y-%M-%d %H:%M:%S%z"
>>>local.strftime(fmt3)
'2015-29-21 04:29:00-0700'

Is there an example of the desired properly formated string?

2 Answers

Hi Chris,

What's the full code that you're trying to pass with?

The challenge already provides you with an fmt string that you should use when creating the pytz_string variable. You don't have to create your own.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,457 Points

Thanks. That wasn't clear to me from the wording of the challenge: "Now create a variable named pytz_string that is the fmt string from the local datetime."

I was over-reading the text. I was reading it as literally needing to find a fmt string from the local datetime. Since local datetime doesn't have an an attribute or method from which to obtain a fmt string, it lead me to think they wanted a format defined to be the same as the format that str() returns on a tz aware datetime, such as local. Insane as that seemed, I was then trying to mimic that format.

It would be clearer if stated as "Now create a variable named pytz_string from that the local datetime that is formated using the fmt string provided.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Thanks for the notes! I've updated the code challenge so hopefully it'll make more sense to future students.