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(); ... .. ?>
🐧 4 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
php.ini
worked like a charm!! thanks a lot :)
I tried this and it didnt work for me
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
Congratulations on topic …
Very simple and helped me with such precision .. My error_log files were growing too!
thank you