Jump to content

It is not safe to rely on the system's timezone settings. HELP!


thecoffeeguy

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

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

 

 

 

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.