Linux: phpinfo() system’s timezone error date.timezone

by on January 18, 2011 · 4 comments· LAST UPDATED January 18, 2011

in , ,

I'm getting the following errors in my log file whenever I use phpinfo() function:

[10-Jan-2011 18:39:08] PHP Warning: 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/Chicago' for 'CST/-6.0/no DST' instead in /home/servers/http/dev/testpc.php on line 2

How do I fix this problem under UNIX / Linux php running Apache or lighttpd web server?

This problem or warning can be easily fixed by editing the /etc/php.ini file. Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following commands or login using ssh to the remote server. First find out your timezone from /etc/sysconfig/clock file, enter:
# cat /etc/sysconfig/clock
ZONE="America/Chicago"
UTC=true
ARC=false

Edit /etc/php.ini, enter:
# vi /etc/php.ini
Make the changes as follows, enter (find date.timezone and update it as follows):

 
date.timezone="America/Chicago"
 

Save and close the file. Restart the Apache server:
# service httpd restart
If you are using lighttpd type the following to restart it:
# service lighttpd restart
Note: If you don't have access to the /etc/php.ini file, add the following line in your php file before any date related functions:

 
<?php
   ....
   ....
        date_default_timezone_set("America/Chicago");
        phpinfo();
  ...
 ..
?>
 
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 BeDa January 18, 2011 at 12:48 pm

php.ini

date.timezone = “US/Central”

Reply

2 Sri Prasanth March 28, 2012 at 10:28 pm

worked like a charm!! thanks a lot :)

Reply

3 Ryan September 4, 2012 at 4:20 am

I tried this and it didnt work for me

cat /etc/sysconfig/clock
ZONE="America/Los_Angeles"
UTC=true
ARC=false

I’ve tried everything that I’ve found even on here.

Time Zone Warning
Similar to the Deprecated Warning, you may see the following warning in your logs
PHP Warning: strtotime(): 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 ‘Europe/Berlin’ for ‘CET/1.0/no DST’ instead in
/usr/share/cacti/include/global_constants.php on line 156
In this case, simply follow the directions. Set your timezone in /etc/php.ini
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone =America/Regina
Of course, read http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone , and find your correct timezone.
As always, restart apache after any change to /etc/php.ini

I still get this error.

Warning: strtotime() [function.strtotime]: 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 /var/www/html/include/global_constants.php on line 165

Reply

4 Rodolfo Souza July 2, 2013 at 12:31 pm

Congratulations on topic …
Very simple and helped me with such precision .. My error_log files were growing too!

thank you

Reply

Leave a Comment

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: