`
dbaspider
  • 浏览: 256365 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

PHP Warning: phpinfo(): It is not safe to rely on the system's timezone setting

    博客分类:
  • PHP
阅读更多

php默认错误日志路径:C:\Windows\Temp\php-errors.log,经常看看,能帮你发现很多潜在的问题,可能这些问题并不影响正常运行。

错误描述:
PHP Warning:  phpinfo(): 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 C:\info.php on line 4

解决办法:

打开php.ini 配置文件
找到
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =


修改为:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone =PRC


然后记得重启apache!

另外,还有下面两种办法(不建议)

1、在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');

2、在页头使用 ini_set('date.timezone','Asia/Shanghai');

对于中国,可选值:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi (依次为重庆,上海,乌鲁木齐)港台地区可用:Asia/Macao ,Asia/Hong_Kong ,Asia/Taipei (依次为澳门,香港,台北),还有新加坡:Asia/Singapore,老的PRC也行。

PHP所支持的时区列表可参见:http://www.php.net/manual/zh/timezones.php
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics