Home  >  Article  >  Backend Development  >  php date reads incorrect time_PHP tutorial

php date reads incorrect time_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:53:43849browse

php date reading time is incorrect

$DateTime = date("Y-m-d H:i:s");
echo $DateTime;
Why is the printed date inconsistent with the system time of my server? I'm testing it locally.

Configure php.ini
You can also set it directly to East Eighth District in php.ini:
Open php.ini and search for date.timezone. Remove the semicolon in front of it, add Asia/Shanghai after =, and restart apache

Set in the program

@ini_set('date.timezone','PRC');
$DateTime = date("Y-m-d H:i:s");
echo $DateTime;
That's it. Add @ini_set('date.timezone','PRC'); above to change the configuration time zone.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632372.htmlTechArticlephp date reading time is incorrect $DateTime = date(Y-m-d H:i:s); echo $DateTime; Why is the printed date inconsistent with the system time of my server? I'm testing it locally. Configure...
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