Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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