Home > php教程 > php手册 > PHP Warning: date(): It is not safe to rely on the system

PHP Warning: date(): It is not safe to rely on the system

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 09:56:27
Original
1006 people have browsed it

昨天碰到使用date()函数时出现PHP Warning: date(): It is not safe to rely on the system出现这种错误是因为php5默认date.timezone为utc,改为date.timezone = PRC即可.下面看我的方法总结。

在php程序中运行时报如下警告信息:

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     

主要是时区没有设置的缘故,调整很简单,

打开php.ini文件,并找到date.timezone这行,改成如下:

 代码如下 复制代码

date.timezone = Asia/Shanghai     

然后重启apache即可!

在php程序中解决,在你程序前段加上


我们可以在php页面中加入

 代码如下 复制代码
date_default_timezone_set('asia/shanghai');

或者

 代码如下 复制代码
ini_set('date.timezone','asiashanghai');
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
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template