What to do if calling time fails in php

藏色散人
Release: 2023-03-13 17:08:01
Original
1611 people have browsed it

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template