php中在获取时间有时会出现这些,
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 the timezone 'UTC' for now, but please set date.timezone to select
your timezone.
解决办法:
在php.ini配置文件中找到date.timezone项,去掉前面的";",添加设置
date.timezone = "Asia/Shanghai"
然后重启环境,就能正常用了,但是如果用不了:
在date.timezone = "Asia/Shanghai"
下加上:
date_default_timezone_set('UTC');
还有另外的一种方法:
在
<?php
date_default_timezone_set('PRC'); //这个样子也是可以的,这种方式属于临时修改
?>