In-depth analysis of strtotime() time zone setting and warning message repair in PHP 5.3.x_PHP Tutorial

WBOY
Release: 2016-07-21 15:00:20
Original
1009 people have browsed it

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 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /var/www/cacti/index.php
check I got some information and said that the PHP version is too high and timezone must be specified in the new version.

The specific operation method is as follows:
1. Add the timezone configuration in the php configuration file
(refer to the debian configuration rules and add a small configuration rule file That’s it, easy to maintain and easy to customize)
~# vim /etc/php/cli-php5.3/ext-active/date_timezone.ini
date.timezone = "Asia/Shanghai"
~ # env-update
~ # source /etc/profile
The customized files are placed in the cli-php5.3/ext-active directory because php uses the cli method by default, and the ext-active directory It is a special directory that represents enabled features. This can be seen from the /etc/env.d/20php5.3 file
MANPATH="/usr/lib/php5.3/man/"
CONFIG_PROTECT_MASK="/ etc/php/cli-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/apache2-php5.3/ext-active/"

2. Add date_default_timezone_set('Asia/Shanghai') in the php file where the error message appears; the location is Shanghai, China

Note:
In some reference materials, it is said that any one of these two methods can be used, but after my test, both methods must be used at the same time. , the error message will no longer appear.

According to actual testing, the second method does not need to be added to every PHP file where an error message appears. It only needs to be added to one of the PHP files. In addition, the added time zone does not need to be the same as the time zone in the prompt. For example, the prompt given to me by the system is Chongqing, but it is the same if I set it to Shanghai. Of course, this time is also the same as the time zone setting of my system.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328081.htmlTechArticlePHP 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....
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template