Home  >  Article  >  Backend Development  >  这个动态获取服务器时间为什么和正常时间差8个小时,该如何解决

这个动态获取服务器时间为什么和正常时间差8个小时,该如何解决

WBOY
WBOYOriginal
2016-06-13 13:36:451251browse

这个动态获取服务器时间为什么和正常时间差8个小时
问题如上所述,已仔细看过代码,新手求指教!代码如下


 
 
 


 
 
 
 
 
 
 
 
 
 

------解决方案--------------------
如果你确认代码没问题 刚好差了8个小时,那么 服务器php.ini 添加 date.timezone = "Asia/Chongqing"

restart apache.
------解决方案--------------------
默认的格林时间比正常时间早8小时。 改改时区设置即可。
------解决方案--------------------
php.ini 添加 date.timezone = "Asia/Chongqing"
------解决方案--------------------
在程序最前边加上一句话:date_default_timezone_set('PRC');
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