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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-17 09:37:42
Original
1002 people have browsed it

方法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');     
?> 
Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template