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

PHP PHP Basics PHP on the Web Date Function

György Varga
György Varga
19,198 Points

Code challange doesn't accept the right code!

Hi!

So here is my code and it displays the exact same format as in the example, but the Code Challange doesn't mark it correct.

Please Help! Thank you!

index.php
<?php
echo 'Today is ';
//Place your code below this comment
echo date("F j, Y");
?>

1 Answer

andren
andren
28,558 Points

The result might be correct for this specific date, but the date format is not quite right.

The instructions specify that the day of the month should be displayed with a leading 0, with is accomplished with the d format option. You are using the j format option which displays the day of the month without a leading zero.

Those result in the same thing on days with two digits in them like today, but would look different on certain other days.

If you replace j with d like this:

<?php
echo 'Today is ';
//Place your code below this comment
echo date("F d, Y");
?>

Then your code will be accepted.