Home >Backend Development >PHP Problem >What to do if calling time fails in php

What to do if calling time fails in php

藏色散人
藏色散人Original
2021-11-03 10:07:471612browse

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.

What to do if calling time fails in php

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!

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