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

Why is this "Bummer"?

I don't understand why is this a "Bummer"?

index.php
<?php

//Place your code below this comment
$today = date("F j, Y");
echo 'Today is ' . $today . '';
?>

"As a developer, you'll spend a lot of time in the documentation. For this code challenge, you'll need to check out the documentation for the date function to see details about formatting. Use a SINGLE date function to display today's date in the message. Use the following format: full month, day of the month with leading 0, comma and 4 digit year. Example: Today is July 04, 2016" (This is the task) I wrote the code in the workspace and I get always a perfect output. But still it's saying it's a bummer. Just... why?

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi there,

You're on the right track, but there are a couple of things wrong here.
First, you are using the wrong character for the day, to display with 2 digits (so, with the leading 0), you need to use "d", not "j".

Second, while the code is correct in syntax, it is not what the instructions are telling you to do. There was a line of code that was pre-loaded, but you deleted it and it needs to be there. Never delete pre-loaded code.
Also, the instructions never asked to create a variable, not did it say to concatenate the string for the sentence.
In the code window, there is a comment that say to "Place your code below this comment". While you did, you also deleted the code above, therefore, altering the challenge.

You only need one line of code for the answer, which you have. But, instead of assigning it to a variable, you just need to echo it out (with the corrected date code).

So, give a challenge a reset and give it another go with this in mind.
Hint: You will only add one line of code, and it is an echo statement.

Keep Coding! :dizzy:

Did it. Thank you!