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 trialLouis Samuel
12,529 PointsCan't pass code challenge - PHP Basics
I don't understand why this won't pass, says wrong string for formatting?
<?php
echo 'Today is ' . date("F d") . ", " . date("Y");
//Place your code below this comment
//echo date("F d") . ", " . date("o");
?>
4 Answers
Matthew Carson
5,965 PointsJust call the date() function once. You can add the comma in the format string:
<?php
date("F d, Y");
Louis Samuel
12,529 PointsThanks Matthew, this worked.
Odd wouldn't pass as output is the same but probably better to only call the function once as you say.
tobiaskrause
9,160 PointsVery strange
<?php
echo 'Today is ';
//Place your code below this comment
echo date("F j, Y");
?>
is exaclty the same format but won't work
Matthew Carson
5,965 PointsThe challenge is asking for the day of the month with the leading zero.
It should be a d in place of the j.
For example:
j is for 3
d is for 03
tobiaskrause
9,160 PointsWell yeah i dont recognized that because we have the 19th thought it would be the same
Eric Samouilidis
4,430 PointsI think the problem is on treehouse side. I put the following code and it keeps coming up with an error that i forgot to use echo... <?php echo 'Today is ' . date('m-d-Y'); ?> It shows correct on the preview but it wont pass the challenge
Louis Samuel
12,529 PointsLouis Samuel
12,529 PointsTo clarify, my other attempt is commented out. Says "You have not passed the correct string for formatting"