方法1:
找到php.ini中的“;date.timezone =”这行,将“;”去掉,改成“date.timezone = PRC”(PRC:People's Republic of China 中华人民共和国),重启Apache,问题解决。
方法2:
在php5以及起以上的版本,要输出本地的时间(限中国),可以这么写代码:
PHP代码
date_default_timezone_set('Asia/Shanghai');
echo date('Y-m-d H:i:s');
?>
也可以这样写代码:
PHP代码
date_default_timezone_set('Asia/Chongqing');
echo date('Y-m-d H:i:s');
?>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn