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

Louis Samuel
Louis Samuel
12,529 Points

Can't pass code challenge - PHP Basics

I don't understand why this won't pass, says wrong string for formatting?

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

?>
Louis Samuel
Louis Samuel
12,529 Points

To clarify, my other attempt is commented out. Says "You have not passed the correct string for formatting"

4 Answers

Matthew Carson
Matthew Carson
5,965 Points

Just call the date() function once. You can add the comma in the format string:

<?php
date("F d, Y");
Louis Samuel
Louis Samuel
12,529 Points

Thanks Matthew, this worked.

Odd wouldn't pass as output is the same but probably better to only call the function once as you say.

Very strange

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

is exaclty the same format but won't work

Matthew Carson
Matthew Carson
5,965 Points

The challenge is asking for the day of the month with the leading zero.

It should be a d in place of the j.

For example:

j is for 3

d is for 03

Well yeah i dont recognized that because we have the 19th thought it would be the same

Eric Samouilidis
Eric Samouilidis
4,430 Points

I think the problem is on treehouse side. I put the following code and it keeps coming up with an error that i forgot to use echo... <?php echo 'Today is ' . date('m-d-Y'); ?> It shows correct on the preview but it wont pass the challenge