How to set the time zone error in php. Php users use the standard time of Lin Weizhi, so it is related to Beijing time for 8 hours. many friends will find a time difference of 8 hours when using phpdate and time, next, let's take a look at the standard time of Lin Weizhi for php users, so it is related to Beijing time for 8 hours. many friends will find a time difference of 8 hours when using php date and time to get the time, next let's look at the solution.
The simplest method is as follows:
The code is as follows: |
|
Date_default_timezone_set ("Etc/GMT + 8"); // This is 8 hours slower than the standard time of Linwei governance ?> |
This solves the problem of 8 hours of time difference.
How to set the Beijing Time zone:
The code is as follows: |
|
Date_default_timezone_set ('prc'); // Set the China time zone ?> |
The ini_set () function sets the time zone:
Can be added at the beginning of the file
The code is as follows: |
|
Ini_set ('date. timezone ', 'Asia/Shanghai'); // 'Asia/Shanghai' |
Shanghai time zone
All of the above are set in the php program, but some time programs are invalid. let's take a look at the operation method in php. ini.
Manually modify php. ini settings
Open php and find
The code is as follows: |
|
Date. timezone = "PRC" |
If the semicolon is removed, add it manually!
Returns the time difference of 8 hours when obtaining the latest date and time. let's take a look at it...