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.
Jake Williams2,667 Points
Why isn't it returning the right year.
Examples I am finding show that this is right but it isn't returning the right year. Is there something else I need to do?
import datetime ## Examples # to_string(datetime_object) => "24 September 2012" # from_string("09/24/12 18:30", "%m/%d/%y %H:%M") => datetime def to_string(date1): return date1.strftime('%d %B %Y')
Jennifer NordellTreehouse Teacher
Hi there, Jake Williams! You're super close. The example it lists is just that... an example. So it's not expecting 2012, it's expecting 2015. The problem here is that you have a few too many spaces in that string. You have two spaces between the day and the month and two spaces between the month and the year instead of just one space between each.
So where you have:
# too many spaces date1.strftime('%d %B %Y')
# note the spacing date1.strftime('%d %B %Y')
Hope this helps!