nepzap2 Posted November 9, 2011 Share Posted November 9, 2011 Hello everyone, I updated my version of php and since, a piece of code that always seemed to work no spits out the following Warning: 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 'America/New_York' for '-5.0/no DST' instead in C:\Abyss Web Server\htdocs\bti.cornell.edu\includes\home_news.php on line 13 The simple code was the following: <?php $currYear = date("Y"); echo "<li><a href='index.php?page=NewsArchive&year=$currYear' class='moreInformation'>News Archive</a></li>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/250779-i-just-need-the-curryear/ Share on other sites More sharing options...
AyKay47 Posted November 9, 2011 Share Posted November 9, 2011 can't say i've seen this error before, but why don't you look at what it is telling you to look at.. what is you default.timezone directive set to in your php.ini file? Quote Link to comment https://forums.phpfreaks.com/topic/250779-i-just-need-the-curryear/#findComment-1286643 Share on other sites More sharing options...
nepzap2 Posted November 9, 2011 Author Share Posted November 9, 2011 Thanks AyKay47 Below are my settings [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone = ; http://php.net/date.default-latitude ;date.default_latitude = 31.7667 ; http://php.net/date.default-longitude ;date.default_longitude = 35.2333 ; http://php.net/date.sunrise-zenith ;date.sunrise_zenith = 90.583333 ; http://php.net/date.sunset-zenith ;date.sunset_zenith = 90.583333 [filter] ; http://php.net/filter.default ;filter.default = unsafe_raw ; http://php.net/filter.default-flags ;filter.default_flags = Quote Link to comment https://forums.phpfreaks.com/topic/250779-i-just-need-the-curryear/#findComment-1286660 Share on other sites More sharing options...
AyKay47 Posted November 9, 2011 Share Posted November 9, 2011 yes, you are receiving this error because your date.timezone directive is empty.. you will need to assign it the correct value in order to correctly use the date function.. ;date.timezone = "America/New_York" or whatever timezone you are in, alternatively, you can use date_default_timezone_set() to set the timezone of the executing page, however, this will need to be called on all of your pages and I would recommend chaning the php.ini directive to effect all of your pages.. Quote Link to comment https://forums.phpfreaks.com/topic/250779-i-just-need-the-curryear/#findComment-1286664 Share on other sites More sharing options...
nepzap2 Posted November 9, 2011 Author Share Posted November 9, 2011 Hello AyKay47, Thank you. Removing the ";" from ";date.timezone = "America/New_York"" solved the problem. Quote Link to comment https://forums.phpfreaks.com/topic/250779-i-just-need-the-curryear/#findComment-1286696 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.