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

Cate C
Cate C
4,734 Points

Erroneously marking correct code as wrong

My code returns the correct date and is correctly constructed. PHP documentation clearly states " timestamp is optional and defaults to the value of time()" yet my code is marked as incorrect and the "bummer" response implies that I MUST provide a second parameter for the date function. Why is this being registered as incorrect?

index.php
<?php
echo 'Today is ';
//Place your code below this comment
echo date('F d\, Y' );
?>
Cate C
Cate C
4,734 Points

Thanks for the answers. removed the slash and it worked.

2 Answers

Kieran Barker
Kieran Barker
15,028 Points

You don’t need that backslash.

andren
andren
28,558 Points

It's being marked as incorrect because the challenge checker for this task does not just look at your output, it looks for this exact text: date('F d, Y') if it does not find that exact string of characters (including the same spacing) then it won't accept the code.

Part of the reason for that is that with this challenge it is possible to get the right output without using the right code. For example you could just print out the actual date by writing it by hand rather than using the date function, or you could use the j (day without leading 0) symbol in place of the d (day with leading 0) symbol when formatting the date. That would produce the right output on any date that does not need a leading 0 to be two digits long.

Ideally the code checker would be written to check for those two scenarios specifically rather than being hardcoded is such a strict way, but that is just how it was setup for this particular exercise.

So if you change your code to this:

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

Then your code will be accepted.