Home > Backend Development > PHP Tutorial > PHP警告date(): It is not safe to rely on the system_PHP教程

PHP警告date(): It is not safe to rely on the system_PHP教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:56:31
Original
1091 people have browsed it

When using PHP version 5.3 or above, a Warning will be reported as long as time is involved: date(): It is not safe to rely on the system's timezone settings.

It generally means that the timezone is not set. In China, Green + 8 hours is used, so it needs to be set up.

The first type

Add the following statement to the head of the page

Find the date.timezone line in php.ini and change the value to PRC, such as
The code is as follows
 代码如下 复制代码

 date_default_timezone_set("PRC");  或 ini_set('date.timezone','asiashanghai');

Copy code


date_default_timezone_set("PRC"); or ini_set('date.timezone','asiashanghai');

 代码如下 复制代码

date.timezone = PRC。

One disadvantage of this method is that all pages must be added

Second type

The code is as follows
Copy code

date.timezone = PRC. If there is no such line, just add it directly. Finally, restart the WEB server and PHP. Friendly reminder: In fact, from PHP 5.1.0, when using functions such as date(), if the timezone is set incorrectly, E_NOTICE or E_WARNING information will be generated every time the time function is called. And in php5.1.0, the date.timezone option is turned off by default. No matter what php command is used, it is Greenwich Mean Time. However, in PHP5.3, it seems that this will be forcibly thrown out if it is not set. Wrong, to solve this problem, just localize it.
http://www.bkjia.com/PHPjc/632160.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632160.htmlTechArticleWhen using PHP versions above PHP5.3, a Warning will be reported as long as time is involved: date() : It is not safe to rely on the system's timezone settings. Generally speaking, timezone is not set...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template