PHP configuration. It is unsafe to rely on the system time zone settings

It's weird here. I am just upgrading to php 5.3.0, and from the moment of upgrade I get the following warning:

Warning: getdate () [function.getdate]: It is not safe to rely on a time zone configuration system. You need to use the date.timezone setting or the date_default_timezone_set () function. If you used any of these methods, and you still receive this warning, you most likely incorrectly entered the time zone identifier. We chose 'America / Chicago' for 'CST / -6.0 / no DST'

After browsing in different forums, everyone says that to solve the problem all you need to do is edit the date zone in php.ini and restart Apache.

This did not work for me.

I tried

date.timezone="America/New_York" date.timezone=America/New_York date.timezone="US/Central" 

Restarting apache after making changes.

Since I still have the old php install version, I even made sure that I was editing php.ini that the current php version was using at the time to load

/usr/local/php5/lib/php.ini

A warning still appears.

Any suggestions?

Thanks for taking the time.

+63
timezone php
Feb 06 2018-10-06
source share
12 answers

Chalvak, who commented on the original question, kicked me on the head. I edited (I use Debian):

 /etc/php5/apache2/php.ini 

... which had the correct time zone for me and was the only .ini file that loaded the .timezone date inside it, but I got the above error when I ran the script through Bash. I had no idea what I needed to edit:

 /etc/php5/cli/php.ini 

. (Well, for me it was β€œalso”, it could be different for you, but I'm going to save my php.ini versions for Apache and CLI for now).

+37
Apr 12 2018-12-12T00:
source share

You tried to set the time zone for the func function: http://pl.php.net/manual/en/function.date-default-timezone-set.php

+14
Feb 06 2018-10-06
source share

I had to configure Apache and PHP on two laptops recently. After a lot of crying and gnashing of teeth, I noticed in the output of phpinfo that (for some reason: not paying attention during the installation of PHP, a poor installer) Apache expected that php.ini would be somewhere where it was not.

Two options:

  • put it where Apache thinks it should be or
  • point Apache to the true place of your php.ini

... and restart Apache. At this point, you should determine the time zone settings.

+7
Dec 06 2018-11-12T00:
source share

Open the .htaccess file, add this line to the file, save and try again:

 php_value date.timezone "America/Sao_Paulo" 

This works for me.

+6
Feb 03 '15 at 6:56
source share

try this, it works for me.

 date_default_timezone_set('America/New_York'); 

In the file itself that complained.

+5
Nov 21 '14 at 3:05
source share

Check for syntax errors in the php.ini file, especially before the Date parameters, which prevent the file from processing correctly.

+2
Feb 06 '10 at 16:32
source share

Change index.php as follows:

 require_once($yii); $app = Yii::createWebApplication($config); Yii::app()->setTimeZone('UTC'); $app->run(); 
+2
Feb 12 '14 at 17:09
source share

Obviously, I'm a little out of season on this issue, but for the benefit of the next sufferer: I had this problem, and in my case (unlike the OP, which tried the same without success), the fix should have been reviewed by php.ini, the change

 date.timezone = America/New York 

to

 date.timezone = America/New_York 

This is an underline addition.

+1
01 Sep '14 at 23:05
source share

I changed /etc/php.ini

[Date of] ; Defines the default time zone used by date functions; http://php.net/date.timezone date.timezone = ('Asia / kolkata')

and now it works fine.

Vipin pal

+1
Oct 26 '14 at 0:52
source share

You may have forgotten to remove the semicolon to uncomment this line. For date.timezone = "US/Central" make sure that there is no semicolon before this point.

0
Mar 02 '15 at 18:14
source share

I found it was strange that I could fix errors by posting the timezone declaration in the TOP of my php.ini file.

This was already in my php.ini. In fact, twice. And I pulled out my hair because everyone said that something else had to be loaded ... It wasn’t.

Hope this can save someone else time / hair loss.

0
Mar 24 '15 at 11:05
source share

You can also try this.

 date.timezone = <?php date('Y'); ?> 
-10
Jun 14 '13 at 20:38
source share



All Articles