Solution to the inaccurate current time obtained by php: 1. Open the php.ini file, and then modify "date.timezone="PRC""; 2. Use the "date_default_timezone_set(")" method to obtain the time.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer.
PHP date() obtains the system time incorrectly What should I do?
I use PHP to get the system time and find that the time is wrong. This is because the default time zone of PHP is UTC and its time zone should be set to Beijing time.
Method 1: Modify the php.ini file
Open the php.ini file: left-click the WampServer icon in the lower right corner - PHP - php.ini,
Look for date.timezone , find date.timezone = "UTC",
Change it to date.timezone = "PRC", if there is a semicolon on the left side of date.timezone, remove the semicolon.
Method 2: Use the date_default_timezone_set(”) method;
[Recommended learning:PHP video tutorial]
The above is the detailed content of What should I do if the current time obtained by php is incorrect?. For more information, please follow other related articles on the PHP Chinese website!