Home > php教程 > php手册 > php date读取时间不正确

php date读取时间不正确

WBOY
Release: 2016-06-13 09:54:38
Original
760 people have browsed it

php date读取时间不正确

$DateTime   =   date("Y-m-d   H:i:s");
   echo $DateTime;
为啥打印出来的日期和我服务器的系统时间不一致啊。我是在本地测试啊。

配置php.ini
也可以在php.ini中直接设置成东八区:
打开php.ini查找date.timezone 去掉前面的分号,= 后面加Asia/Shanghai,重启apache

在程序中设置

@ini_set('date.timezone','PRC');
$DateTime   =   date("Y-m-d   H:i:s");
echo $DateTime;
这样就可以了,在上面加上@ini_set('date.timezone','PRC');是改变配置时区的。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template