欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-06-09 09:16:17
...
昨天碰到使用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');

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632167.htmlTechArticle昨天碰到使用date()函数时出现PHP Warning: date(): It is not safe to rely on the system出现这种错误是因为php5默认date.timezone为utc,改为date.timezone = PRC即...