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 Arrays and Control Structures PHP Conditionals Switch Case Statements

Roberto Rivera
Roberto Rivera
11,361 Points

Why is it showing Saturday instead of Friday?

I'm having problems with this code. I copy and paste it and it's outputting the wrong day. It should show Friday but it keeps showing Saturday. I tried running date('l') on another online text editor but it outputs the same. Does anyone understand why this is happening?

ajbor
seal-mask
.a{fill-rule:evenodd;}techdegree
ajbor
Full Stack JavaScript Techdegree Student 5,086 Points

I ran into the same problem and found the solution at this W3 schools.

You need to set the timezone to the one you're in like this before calling the date() function:

date_default_timezone_set("America/New_York");

1 Answer

According to the calendar, the day you posted this question in the community (May 5th) was Saturday, so according to the timezone, the date() function printed the Saturday message.