thecoffeeguy Posted April 27, 2011 Share Posted April 27, 2011 Hey everyone. I was hoping to get some help on something that I am working on. First, I hope this is the right place to post this. Please forgive me if this is the wrong forum. I am new to PHP as I work mostly as a Sys Admin. Recently, I have been working on a project running a number of applications on PHP. I configured a box and a PHP application that has a web interface. Everything looks good except for when I log into the web interface. I am greeted with this message: Warning: date() [function.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/Los_Angeles' for 'PDT/-7.0/DST' instead in /usr/local/www/base/base_main.php on line 138n I have done a lot of research trying to figure out what is causing this. A lot of websites and posts on other sites suggested that the fix would be to make a change in the php.ini file in the : date.timezone section. I did make that change, however the issue still persists. I decided to make a quick test.php file to read the configuration file and see if I can get additional information. I opened up the test.php web page and made sure I was reading the correct configuration file. Which, according to the test page, I am. Moving forward, under the DATE section of the test.php file, I see this: Warning: phpinfo() [function.phpinfo]: 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/Los_Angeles' for 'PDT/-7.0/DST' instead in /usr/local/www/apache22/data/test.php on line 2 Which is what I see as well when I log into the application's interface. Under that date section, it says the following: Default timezone -- America/Los_Angeles Which is my timezone. For a test, I changed the "date.timezone" section in my php.ini file to "America/New York", restarted apache and loaded the config file backup. Looking at the date section again, the error is still there and the DEFAULT TIMEZONE is still pointing to "America/Los_Angeles". So it appears that its not reading my config file or I am completely missing something. Here is the full section of the DATE part of the test.php file: date/time support enabled "Olson" Timezone Database Version 2011.4 Timezone Database internal Default timezone America/Los_Angeles Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone no value no value I have been trying to figure this out for the past few day with no luck. I was hoping someone might be able to help me out here. Thanks for the help. TCG Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/ Share on other sites More sharing options...
Pikachu2000 Posted April 27, 2011 Share Posted April 27, 2011 Did you restart Apache after editing the php.ini file? Are you sure you edited the correct file, as shown in the "Loaded config file" entry of phpinfo()? Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1206996 Share on other sites More sharing options...
thecoffeeguy Posted April 27, 2011 Author Share Posted April 27, 2011 Did you restart Apache after editing the php.ini file? Are you sure you edited the correct file, as shown in the "Loaded config file" entry of phpinfo()? Yep. Restarted apache several times. Here is from the config page: Configuration File (php.ini) Path /usr/local/etc Loaded Configuration File /usr/local/etc/php.ini Scan this dir for additional .ini files /usr/local/etc/php And on my FreeBSD box, I did a find to locate all php.ini files: secids# find / -type f -name php.ini -print /usr/local/etc/php.ini It only found the one, which is what I have been editing. This does have a MySQL database on the backend. Could that have anything to do with it? Thx TCG Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1206998 Share on other sites More sharing options...
Pikachu2000 Posted April 27, 2011 Share Posted April 27, 2011 What happens if you pick a different setting (such as display_errors) and change it? Does it show the new value after restarting Apache and running phpinfo()? Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207000 Share on other sites More sharing options...
thecoffeeguy Posted April 27, 2011 Author Share Posted April 27, 2011 What happens if you pick a different setting (such as display_errors) and change it? Does it show the new value after restarting Apache and running phpinfo()? I will give that a shot. Whats the best way to do that when editing php.ini? Is it: display_errors: Off ? Thx Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207001 Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2011 Share Posted April 27, 2011 America/New_York Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207002 Share on other sites More sharing options...
Pikachu2000 Posted April 27, 2011 Share Posted April 27, 2011 America/New_York ^^^ Good catch; should take care of the problem . . . Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207004 Share on other sites More sharing options...
thecoffeeguy Posted April 27, 2011 Author Share Posted April 27, 2011 America/New_York That was a mistype in my thread. It is correct in the php.ini file. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207005 Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2011 Share Posted April 27, 2011 What's the actual statement that is in your php.ini? I suspect it is commented out. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207007 Share on other sites More sharing options...
Pikachu2000 Posted April 27, 2011 Share Posted April 27, 2011 Actually, copy and paste from a couple lines before to a couple lines after the default.timezone line in your php.ini file in here. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207009 Share on other sites More sharing options...
thecoffeeguy Posted April 27, 2011 Author Share Posted April 27, 2011 Actually, copy and paste from a couple lines before to a couple lines after the default.timezone line in your php.ini file in here. Here is a snippet from the php.ini file: ;;;;;;;;;;;;;;;;;;; ; Module Settings ; ;;;;;;;;;;;;;;;;;;; [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = "America/New_York" ; 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 = I appreciate the help. TCG Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207014 Share on other sites More sharing options...
thecoffeeguy Posted April 27, 2011 Author Share Posted April 27, 2011 hehehe... Looks like i found a doozy of a weird issue. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207074 Share on other sites More sharing options...
Pikachu2000 Posted April 27, 2011 Share Posted April 27, 2011 It may or may not make a difference, but remove the quotes, restart Apache and see what the value is that shows up in phpinfo() after doing that. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207124 Share on other sites More sharing options...
thecoffeeguy Posted April 28, 2011 Author Share Posted April 28, 2011 It may or may not make a difference, but remove the quotes, restart Apache and see what the value is that shows up in phpinfo() after doing that. Ya, tried that but no luck. I think I am going to rebuild PHP, see if that makes a difference. Worth a shot. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207764 Share on other sites More sharing options...
Pikachu2000 Posted April 28, 2011 Share Posted April 28, 2011 If you change a directive in the ini file that shows as the one being loaded in the output of phpinfo(), and that change is not reflected when phpinfo() is called again, it can indicate a syntax error in the ini file. For that reason, it's usually best to make a backup copy of the file before editing it. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207802 Share on other sites More sharing options...
QuickOldCar Posted April 28, 2011 Share Posted April 28, 2011 This is the correct way date.timezone = America/New_York And the results in phpinfo should read as this date date/time support enabled "Olson" Timezone Database Version 2008.2 Timezone Database internal Default timezone America/New_York Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone America/New_York America/New_York Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207816 Share on other sites More sharing options...
mikosiko Posted April 28, 2011 Share Posted April 28, 2011 this caught my attention: date/time support enabled "Olson" Timezone Database Version 2011.4 Timezone Database internal Default timezone America/Los_Angeles Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone no value no value the Default timezone is set but the last line date.timezone shows "no value"... I agree with Pica that most likely you have an error in your php.ini ... I'm guessing that you have a second line in some place with this (or similar): date.timezone = tested on my side and I can reproduce your issue exactly.... check that... maybe that is the problem. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207824 Share on other sites More sharing options...
thecoffeeguy Posted April 28, 2011 Author Share Posted April 28, 2011 If you change a directive in the ini file that shows as the one being loaded in the output of phpinfo(), and that change is not reflected when phpinfo() is called again, it can indicate a syntax error in the ini file. For that reason, it's usually best to make a backup copy of the file before editing it. So just for giggles, I renamed my php.ini file to php.ini.bak and restarted apache. I loaded up test.php file again and it still shows the error. It did say that it did NOT read a configuration file. "Loaded configuration file: (none)" Is what was displayed in the interface. This is very odd. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207861 Share on other sites More sharing options...
Pikachu2000 Posted April 28, 2011 Share Posted April 28, 2011 Then that would seem to confirm there's a syntax error somewhere in the ini file. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207864 Share on other sites More sharing options...
PFMaBiSmAd Posted April 28, 2011 Share Posted April 28, 2011 Try putting the setting in at the start of your php.ini or make a php.ini that only contains that setting. That would tell you if there is a syntax error somewhere in your php.ini and you would just need to locate where it is at by moving the setting down in the php.ini until it stops working. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207866 Share on other sites More sharing options...
thecoffeeguy Posted April 28, 2011 Author Share Posted April 28, 2011 Try putting the setting in at the start of your php.ini or make a php.ini that only contains that setting. That would tell you if there is a syntax error somewhere in your php.ini and you would just need to locate where it is at by moving the setting down in the php.ini until it stops working. So ya, after reading the above posts, I did just this: created a brand new php.ini file and just put in: date.timezone = America/Los_Angeles Voila! Errors gone. So something screwy in the original php.ini file. I will see if I can dig it out. Thanks everyones help! I greatly appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/234880-it-is-not-safe-to-rely-on-the-systems-timezone-settings-help/#findComment-1207888 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.