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

Justin Radcliffe
Justin Radcliffe
18,987 Points

Beginner's PHP Task 1 of 1

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

I dont think this == bummer! Looks like you forgot to include echo

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

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Justin,

Sorry, but that is a Bummer! for two reasons:

  1. You deleted/altered some of the pre-loaded code. This will almost always result in a Bummer. Never touch the code that is loaded into the challenge for you unless explicitly instructed to do so.
  2. You created a variable ($date) that was not asked for. Again, unless explicitly instructed to do so, don't do what the instructions don't tell you to do.

You've got all the right pieces, just need a little bit of rearranging.

For this challenge, you only need to add one short line of code... You just need to echo out the date function. The echo statement pre-loaded provides the first part, you just need to add the second part. Because there is no new line break in the PHP code, any additional echo statements will just be added to the last on the same line.

So, all you need is:

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

Hope that clears it up for you. :)

Keep Coding! :dizzy:

Justin Radcliffe
Justin Radcliffe
18,987 Points

Thanks Jason, that cleared it up for me.