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

The function i'm replying is correct but it isn't submiting.

Asked to add date in PHP in a SINGLE line and in a designated format, i did as it asked to but it doesn't let me pass the test.

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

5 Answers

Spenser Hale
Spenser Hale
20,778 Points

Hello Geronimo.

You are very close. In php the left hand parentheses need to be touching the function name, ie with no spaces.

<?php
date('F d, Y');

Additionally, you are duplicating the Today is, so once you fix your function call, it will print Today is Today is September 20, 2018, instead of Today is September 20, 2018. I would remove the "Today is" and just echo the date.

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

Remove the space between date and ('F d, Y') . The following should pass:

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

In the challenge click preview and check the results

Hi Kris. Already did, in the code that got here i know i repeated the echo for 'Today is ' but if i take it away is still the same. It keeps saying "Bummer: You must use the built-in date function".

Thanks Kris and Spencer, that did the job.