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

Is this a technical issue beyond my control? Php basics date question with correct response but not passing...?

So this is the challenge,

"Use the date function to add todays date to the display message in the following format: full month, day of the month with leading 0, comma and 4 digit year. Example: Today is July 04, 2016"

My code below. Ive even looked up peoples questions about this challenge so I know my answer is right... but its not??

hellllppp :(

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

1 Answer

andren
andren
28,558 Points

The challenges can at times be really picky about how your code is formatted. In this case the thing causing an issue is that you have a space between the date and the parenthesis where you type the date string. If you remove the space like this:

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

Then your code will be accepted.

UGHHHH!!!! Thank you!! ughhh I was so sure of myself... :( So if this wasn't a challenge, would this work in the real world? Do the spaces really matter that much?

andren
andren
28,558 Points

In the real world your code would have worked fine. It's more common to not have a space between a function and it's parenthesis, but having one is fine as far as PHP itself is concerned. It ignores whitespace (spaces, tabs, etc) in most instances, so you can technically space your code however you wish.

As I said above this is mainly an issue of the challenge, or to be more precise the code checker that verifies your code being very picky. It is looking for the exact code: echo date('F d, Y'); to be in your solution. And any deviation from that code, even just a space is enough to trip it up.