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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:56:18839browse

Yesterday I encountered a PHP Warning: date(): It is not safe to rely on the system when using the date() function. This error occurred because the default date.timezone of php5 is utc, which was changed to date.timezone = PRC. That’s it. See the summary of my method below.

When running in the php program, the following warning message appears:

PHP Warning: date(): 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 

Mainly because the time zone is not set, the adjustment is very simple,

Open the php.ini file, find the date.timezone line, and change it to the following:

We can add
The code is as follows
 代码如下 复制代码

date.timezone = Asia/Shanghai     

Copy code

date.timezone = Asia/Shanghai


 代码如下 复制代码
date_default_timezone_set('asia/shanghai');
Then restart apache!

To solve it in php program, add
 代码如下 复制代码
ini_set('date.timezone','asiashanghai');
in the front part of your program
to the php page

or

http://www.bkjia.com/PHPjc/632167.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/632167.html
TechArticle
When I encountered the date() function yesterday, a PHP Warning: date(): It is not safe to rely on The system has this error because the default date.timezone of php5 is utc, which is changed to date.timezone = PRC...
Statement:
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