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
Dennis Castillo
16,018 PointsPHP Warning: date() ???
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in F:\CastSystem\webroot\Castillo System\index.php on line 2896
Can someone explain why im getting this on my website? I know it is an error but I dont know where to get start to get it fix... Thanks and God Bless.
4 Answers
Kit Pierce
2,721 PointsJust curious, though. This is just a warning. They can usually be ignored. Is it causing your script to bail? If you're seeing warnings in the output on your website, then you need to adjust your display_errors in your php.ini. For any kind of production environment, you ought to set that to display_errors = Off.
Jacques Vincilione
17,292 PointsAlso, it's on line 2896 of your index.php file. I'd look there and fix the issue :D
J.L. Sparreboom
3,241 PointsYou probably have to set the default timezone in the php.ini file on your server.
It should look something like this:
[Date]
;Defines the default timezone used by the date functions
;http://php.net/date.timezone
date.timezone = "Europe/Amsterdam" // change this timezone to yours and your message should be history
Make sure that after the changes made to the php.ini file you reset your (web)server. Which in my case is IIS which I can simply reset with opening a cmd prompt and typing iisreset. If you use a different server it shouldn't vary much. Just do a google search on hom to reset your (web)server
Also just to double check you can see if php accepted the change by creating an info file
<?php
phpinfo();
?>
And call it in your browser press ctr + F (if your on a windows pc) and type date. You should see additional information beloning to the header DATE. One of the should be "Default timezone" with right next to it your given timezone.
Another way to get rid of this message is to set the default timezone in the called php file itself. Though I recommend the first approach.
Dennis Castillo
16,018 Pointsecho date('Y');
to
date_default_timezone_set('UTC'); echo "Site Content © 2013-" . date("Y");
Thank you guys for all of your help and information that you given to me, I learned a lot. the message are gone... :D Thanks Again and God Bless...