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 Python Dates and Times Date and Time Basics strptime and strftime

Keaton Crihfield
Keaton Crihfield
4,481 Points

I need help

I found what to use but how do I use it

Steven Parker
Steven Parker
229,644 Points

It's not clear what question you are referring to (the quiz has 4). Please quote the specific question the body of your post, and be sure to also identify the "what to use" you mentioned.

You might also want to take a look at this video about Posting a Question.

2 Answers

Rachel Johnson
Rachel Johnson
Treehouse Teacher

Hey Keaton Crihfield , it's not 100% clear what exactly you need help with. But I will try my best!

I'm guessing you are trying to answer this question by filling in the blanks: dt = datetime.strptime('October 21 2023','_____')

In the video preceding this quiz, strptime is introduced from around 04:17. "October 21 2023" is the datetime string. What you need is to input the format based on the format codes provided in the Python documentation

Format codes are a bit like a puzzle! You'll need to find the pieces that match the format of the string that you are trying to turn into a datetime object. Here are the "pieces" that you'll need to look for:

  • "October", which is a month's full name
  • "21", which is a a day of the month
  • "2023" which is a year, including the century

Find those three format codes, and you'll have the answer to your question!

For an even more direct example, check out 5:26 of the video preceding this quiz

I hope this helps :)

Keaton Crihfield
Keaton Crihfield
4,481 Points

dt = datetime.strptime('October 21 2023', ' ')