Home  >  Article  >  Backend Development  >  php time What to do if the time is wrong

php time What to do if the time is wrong

藏色散人
藏色散人Original
2021-03-16 10:25:132702browse

php time is incorrect because the current time zone setting is incorrect. The solution is: first find and open the PHP.ini file; then modify the time to "date.timezone = Asia/Shanghai".

php time What to do if the time is wrong

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

PHP’s time function returns an incorrect time

The time obtained by PHP's time() is very different from the current time. I checked PHP.ini and found that the time zone is wrong. In PHP.ini, the current setting is:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Europe/Paris
; http://php.net/date.default-latitude
date.default_latitude = 48.88778
; http://php.net/date.default-longitude
date.default_longitude = 2.31806

That is, the European Paris time is currently used. Now we change it to Shanghai time

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai
; http://php.net/date.default-latitude
date.default_latitude = 31.5167
; http://php.net/date.default-longitude
date.default_longitude = 121.4500

Save PHP.ini after modification, and then restart the service You can

recommend learning: "PHP Video Tutorial"

The above is the detailed content of php time What to do if the time is wrong. 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