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.

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,521 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.