Home > Backend Development > PHP Tutorial > php时区有关问题

php时区有关问题

WBOY
Release: 2016-06-13 13:11:20
Original
696 people have browsed it

php时区问题

新装了php,用

date("Y-m-d H:i:s");
Copy after login
得出的时间比实际少了8小时。显然,这是时区的问题,如何调整呢?

方法一
在php.ini文件中修改设置
找到date.timezone项,修改其设置

date.timezone = Asia/Shanghai
Copy after login
通过cgi方式运行php的话,记得重启apache配置才会生效。


方法二

如果有权限等问题,可以在PHP代码中进行设置

<?php date_default_timezone_set("Asia/Shanghai");
?>
Copy after login



Related labels:
source:php.cn
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