Home  >  Article  >  Backend Development  >  Solution to the time difference of 8 hours in PHP5_PHP Tutorial

Solution to the time difference of 8 hours in PHP5_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:53:19862browse

Method 1:
Find the line ";date.timezone=" in php.ini, remove the ";" and change it to "date.timezone = PRC" (PRC: People's Republic of China), restart Apache, problem solved.

Method 2:
In php5 and above versions, to output the local time (China only), you can write the code like this:
PHP code

Copy the code The code is as follows:

date_default_timezone_set('Asia/Shanghai'); s'); 
?> 


You can also write code like this:
PHP code

Copy code The code is as follows:
date_default_timezone_set('Asia/Chongqing');
echo date('Y-m-d H:i:s');
?>

http://www.bkjia.com/PHPjc/318743.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318743.htmlTechArticleMethod 1: Find the ";date.timezone=" line in php.ini and remove the ";" , change to "date.timezone=PRC" (PRC: People'sRepublicofChina), restart Apache, ask...
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