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".
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!