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

php时区有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:11:20
Original
718 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:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template