842
2

PHP获取当前时间有错误解决(It is not safe to rely on the system's timezone settings)

2020-03-31
2026-09-03
文章摘要
|

这个是时区问题,这里是一个可以运行的测试

<?php
date_default_timezone_set('PRC');    
echo date('Y-m-d h:i:s', time());
?>

方法一:php.ini中修改为中国时区

date.timezone = PRC

方法二:在php文件中临时设置为中国时区

date_default_timezone_set('PRC');

推荐方法二

评论