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

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

[b]错误描述:[/b]
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

[b]解决办法:[/b]

打开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!

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

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值