The failure to call time in php is because the time zone is not set correctly. The solution is: 1. Set the time zone in php.ini to "China Asia/Shanghai"; 2. Compensate for the time difference in the application. timestamp value.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if the call time fails in php?
Using time in php to get the current hour is incorrect
Solution:
Usually the time zone setting in php.ini It must not be set to China Asia/Shanghai resulting in time difference.
Normal after setting.
You can also compensate the timestamp value based on the time difference in the application. For example, the display time is 8 hours slower.
echo date("Y年m月d日G时i分",time()+8*3600);
It is equivalent to manually implementing the time zone system.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What to do if calling time fails in php. For more information, please follow other related articles on the PHP Chinese website!