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

Cliff Jackson
Cliff Jackson
2,887 Points

Stuck on date format

No really any pre explanation how to format the date and again the challenge is not saying how to output the date ...checked on the manual and did ("F d, Y"); but no idea where to place this or is it assigned as a variable?

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

?>

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! There are a couple of things going on here. Your format string is correct, but you never actually called the date function. Also, you were not meant to alter the beginning line in any way. The comment below it means that you should add an additional echo which calls the date function and echoes out the results. Remember, the line before it doesn't have a newline character so this will all be echoed out on the same line:

// Do not change anything until after the comment below
<?php
echo 'Today is ';
//Place your code below this comment

// This calls the date function and passes in the string. The correctly formatted date will be output immediate after the echo on the previous line
echo date("F d, Y");

?>

Hope this helps! :sparkles:

Cliff Jackson
Cliff Jackson
2,887 Points

Thanks Jennifer, I often get stuck on how they want the output on the code challenge, I figured the format out but didn't know whether to put the sentence I front