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

Ethan Lax
Ethan Lax
782 Points

I'm trying to display the date, formatted as ex:(January 1, 2017) but I keep getting the error "use date('F')".

My input is <?php echo date('F') . ' ' . date('d') . ', ' . date('Y'); ?> I also tried, echo date('F d') . ', ' . date('Y'); and both display the date as required, but the error remains. Please help.

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

1 Answer

Ryan S
Ryan S
27,275 Points

Hi Ethan,

You can think of the input parameter of the date function as the entire output of what you want your date to look like. So all you need to do is replace each part of the string with its corresponding letter, no string concatenation required.

echo date("F d, Y");

Hope this helps.

Ethan Lax
Ethan Lax
782 Points

Thanks for the quick response!... I didn't know I could place the comma with the parameters, which is the only reason I used concatenation in the first place.