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 trialJoy Ahmed
Courses Plus Student 9,687 PointsQuiz
How to echo the following in php:
Today is Wednesday, October 21, 2015.
3 Answers
Erik McClintock
45,783 PointsJoy,
As far as the challenge goes, if you're failing, it's because you're not supposed to add anything more to the challenge code than the echo for the site title. If you try to add anything else, the challenge will consider it as an error, as you might be seeing. So, remove the attempt to echo the date from your challenge code and you'll pass it just fine.
If you're simply interested in knowing how to echo the date elsewhere in that particular fashion using PHP, you would want to use the following:
<?php echo "Today is " . date('l, F d, Y'); ?>
There are a couple of things wrong with the way you've written it:
1) You are missing the dot ( '.' ) that acts as the concatenation symbol in PHP between your "Today is " and the call to the date() function
2) You are trying to add too many parameters to the date function
3) You are adding the wrong parameters to the date() function to display the date in the fashion that you want to
See this resource for more information about the date() function and the parameters that it accepts. From using this, you'll be able to display the date (and time) in any fashion that you want!
Erik
Erik McClintock
45,783 PointsJoy,
Can you please post the code that you've tried thus far so that we can help you figure out where you went wrong?
Erik
Joy Ahmed
Courses Plus Student 9,687 PointsThis is what i did Erik <!DOCTYPE html> <html> <body> <h1><?php echo "Shirts 4 Mike"; ?><h1> <p><?php echo "Today is" date('d', 'm' 'y'); ?><p> </body> </html>
Joy Ahmed
Courses Plus Student 9,687 PointsJoy Ahmed
Courses Plus Student 9,687 PointsThanks a lot bro