Home >Backend Development >PHP Tutorial >PHP5中的时间相差8小时的解决办法_php技巧

PHP5中的时间相差8小时的解决办法_php技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-17 09:37:42996browse

方法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