[php] PHP Configuration: It is not safe to rely on the system's timezone settings

Here a weird one. I just upgrade to php 5.3.0 and since the upgrade I'm getting the following warning:

Warning: getdate() [function.getdate]: 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/Chicago' for 'CST/-6.0/no DST'

After looking in various forums, everybody says that to solve the problem, all you have to do is edit the date zone in the php.ini and restart Apache.

It did not work for me.

I tried

date.timezone="America/New_York"

date.timezone=America/New_York

date.timezone="US/Central"

Restarted apache after I made the change.

Since I still have the older version of php install, I even made sure that I'm editing the php.ini that the current version of php uses at the time to load

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

Still getting the warning.

Any suggestions?

Thanks for taking the time.

This question is related to php timezone

The answer is


try this, it works for me.

date_default_timezone_set('America/New_York');

In the actual file that was complaining.


also you can try this

date.timezone = <?php date('Y'); ?>

You may have forgot to remove the semicolon to uncomment that line. For the date.timezone = "US/Central" line, be sure that there's no semicolon in front of that line.


Obviously I'm a little out of season on this question but for the benefit of the next sufferer: I just had this problem and in my case (in contrast to OP who tried the same without success) the fix was to revise php.ini, changing

date.timezone = America/New York

to

date.timezone = America/New_York

That is adding the underscore.


Please modify your index.php as follows:

require_once($yii);
$app = Yii::createWebApplication($config);
Yii::app()->setTimeZone('UTC');
$app->run();

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

php_value date.timezone "America/Sao_Paulo"

This works for me.



I found, bizarrely, that I could fix the errors by placing the timezone declaration at the TOP of my php.ini file.

It was already in my php.ini. Twice, actually. And I was pulling my hair out because everyone was saying there must be another ini being loaded... There wasn't.

Hope this can save someone else the time/hair loss.


I happened to have to set up Apache & PHP on two laptops recently. After much weeping and gnashing of teeth, I noticed in phpinfo's output that (for whatever reason: not paying attention during PHP install, bad installer) Apache expected php.ini to be somewhere where it wasn't.

Two choices:

  1. put it where Apache thinks it should be or
  2. point Apache at the true location of your php.ini

... and restart Apache. Timezone settings should be recognized at that point.


Check for syntax errors in the php.ini file, specially before the Date paramaters, that prevent the file from being parsed correctly.


I modified /etc/php.ini

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

and now working fine.

Vipin Pal


Tchalvak, who commented on the original question, hit the nail on the head for me. I've been editing (I use Debian):

/etc/php5/apache2/php.ini

...which had the correct timezone for me and was the only .ini file being loaded with date.timezone within it, but I was receiving the above error when I ran a script through Bash. I had no idea that I should have been editing:

/etc/php5/cli/php.ini

as well. (Well, for me it was 'as well', for you it might be different of course, but I'm going to keep my Apache and CLI versions of php.ini synchronised now).