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

Jennifer Klakulak
Jennifer Klakulak
1,004 Points

I think I am stuck somehow on the SINGLE date function. What I currently have was my original thought, but nope

I originally put my current code in and it worked on the preview. But when I check work, it tells me that it is not correct. I have tried every form of what I believe to be the SINGLE date function. I read through the documentation. I tried timestamp. I am stuck.

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

2 Answers

jonathanbarrios
STAFF
jonathanbarrios
Treehouse Teacher

👋 Hi Jennifer,

The problem here is the whitespace in between the date function and the parenthesis. Just remove the white space and this should work:

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

This can be confusing because the documentation looks like it has whitespace in the description:

date ( string $format [, int $timestamp = time() ] ) : string

But if you scroll down and look at the examples, they do not have whitespace.

<?php
// Prints something like: Monday
echo date("l");

// Prints something like: Monday 8th of August 2005 03:12:46 PM
echo date('l jS \of F Y h:i:s A');

// Prints: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));

/* use the constants in the format parameter */
// prints something like: Wed, 25 Sep 2013 15:28:57 -0700
echo date(DATE_RFC2822);

// prints something like: 2000-07-01T00:00:00+00:00
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
?>

I hope this helps and happy coding! 🙌

Jennifer Klakulak
Jennifer Klakulak
1,004 Points

It was the white space between date and parenthesis and the double quotes in front of date. I had to take out everything between the first quotes and the d on date. Then it worked. It looked like it was working before, the quiz just wanted it cleaned up. Thank you.