The simplest method is as follows:
The code is as follows: |
Copy code |
<? Php 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: |
Copy code |
<? Php 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: |
Copy code |
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: |
Copy code |
Date. timezone = "PRC" |
If the semicolon is removed, add it manually!