echo date("Y-m-d H:i:s"); //Current time
?>
The time obtained by this method is 8 hours different from the standard time;
Starting from php5.1.0, the date.timezone option has been added to php.ini, which is turned off by default
That is, the time displayed (no matter what php command is used) is Greenwich Mean Time
It is exactly 8 hours different from our time (Beijing time). There are 3 methods below to restore the normal time.
1. The simplest way is not to use php5.1 or above
2. If you must use it and cannot modify php.ini, you need to add date_default_timezone_set (XXX) to the
statement about time initialization;
cp does not have this problem
3. Once and for all, only php.ini can be modified. Open php.ini and search for date.timezone. Remove the semicolon
= and add XXX after it. Restart the http service (such as apache2 or iis, etc.)
Regarding XXX, the available values in mainland China are: Asia/Shanghai
Available in Hong Kong and Taiwan: Asia/Macao, Asia/Hong_Kong, Asia/Taipei (in order, Macau, Hong Kong, Taipei)
And Singapore: Asia/Singapore