教程集 www.jiaochengji.com
教程集 >  脚本编程  >  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

发布时间:2018-12-23   编辑:jiaochengji.com
教程集为您提供PHP Warning: date(): It is not safe to rely on the system等资源,欢迎您收藏本站,我们将为您提供最新的PHP Warning: date(): It is not safe to rely on the system资源
昨天碰到使用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这行,改成如下:

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy2295')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy2295>

date.timezone = Asia/Shanghai     

然后重启apache即可!

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


我们可以在php页面中加入

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy4550')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy4550>date_default_timezone_set('asia/shanghai');

或者

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy4835')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy4835>ini_set('date.timezone','asiashanghai');

您可能感兴趣的文章:
PHP date()函数It is not safe to rely on the system s timezone settings
PHP Warning: date(): It is not safe to rely on the system
PHP警告date(): It is not safe to rely on the system
PHP5.3以上版本涉及时间的会报错 It is not safe to rely on the system's timezone settings.
php date()时间函数报错,时区问题解决 UTC PRC CST
PHP中设置时区方法总结
A Study of WebRTC Security
php Date()函数输出中文年月日时分秒
Apache Reference Manual (12)
IOCP Thread Pooling in C

[关闭]
~ ~