Problem:
PHP function date("Y-n-d H-i-s"); The output time is 8 hours different from the local time.
Solution ideas
Beijing time is East 8th District, it may be a time zone issue. But there was no problem before After google, I found that starting from php5.1.0, the date.timezone option was added to php.ini. It is turned off by default, which means that 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).
Set the time zone before calling the date() function.
Method 1:
date_default_timezone_set('PRC');
No return value. Now it’s OK to use the date function directly
$time = date(Y."Year".m."Month".d."Day".G."Hour".i."Min");
Method Two:
Modify;date.timezone = in php.ini to date.timezone = "Asia/Shanghai" (or change to date.timezone = PRC)and remove the semicolon in front,restart Apache.
The above introduces the solution to the problem that the date function in PHP52 displays an 8-hour difference from Beijing time when it comes to the operation time of Beijing Subway Line 9, including the operation time of Beijing Subway Line 9. I hope friends who are interested in PHP tutorials can learn from it. help.