Home  >  Article  >  Backend Development  >  p5 Solution to the time difference of 8 hours in PHP5

p5 Solution to the time difference of 8 hours in PHP5

WBOY
WBOYOriginal
2016-07-29 08:37:431168browse

Method 1:
Find the ";date.timezone=" line 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 versions of php5 and above, to output the local time (limited to China), you can write the code like this:
PHP code

Copy the code The code is as follows:


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

date_default_timezone_set('Asia/Chongqing');
echo date('Y-m-d H:i:s');
?>

The above introduces the solution to the 8-hour time difference in p5 PHP5, including p5 content. I hope it will be helpful to friends who are interested in PHP tutorials.

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