PHP出现报警后须要修改 date.timezone 的值(php.ini)

PHP调试的时候出现了警告:php

It is not safe to rely on the system解决方法,其实就是时区设置不正确形成的,本文提供了3种方法来解决这个问题。ide

实际上,从PHP 5.1.0开始当对使用date()等函数时,若是timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息,而又在php中,date.timezone这个选项,默认状况下是关闭的,不管用什么php命令都是格林威治标准时间,可是PHP5.3中若是没有设置部分时间类函数也会强行抛出了这个错误的。
PS:如今因为大部分人使用VPS/云主机,须要本身配置的环境的就更加会容易出现这个状况。
建议:不熟悉PHP环境仍是用比较成熟的一键安装包吧。函数

 

方法1:ui

(最好的方法)在php.ini里加上找到date.timezone项,设置date.timezone = "Asia/Shanghai",重启环境就ok了。this

 

方法2:调试

在须要用到这些时间函数的时候,在页面添加date_default_timezone_set("PRC");get

 

方法3:io

在页头加上设置时区ini_set('date.timezone','Asia/Shanghai');function

 

错误代码:
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 ‘Asia/Chongqing’ for ‘CST/8.0/no DST’ instead

Warning: strtotime(): 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 ‘Asia/Chongqing’ for ‘CST/8.0/no DST’ instead

Warning: date_default_timezone_get(): 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 'Asia/Chongqing' for 'CST/8.0/no DST' instead in <b>/home/ftp/n/nimaboke/include/lib/function.base.phprequire

相关文章
相关标签/搜索