PHP程序报错:It is not safe to rely on the system's timezone settings 打印

  • 3

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. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in D:\PHPWEB\news\file.php on line 17

出现这个问题是因为网站代码里面没有正确设置时区造成的,从PHP 5.3开始,当使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时都会产生E_NOTICE 或者 E_WARNING信息。解决的方法有三种:

方法一、使用较低版本的PHP,如PHP 5.2.17
方法二、在网页页头使用date_default_timezone_set()设置 date_default_timezone_set(‘PRC’);
方法三、在页头使用ini_set(‘date.timezone’,'Asia/Shanghai’);


这篇文章对您有帮助吗?

« 返回

Powered by WHMCompleteSolution