Recently learning PHP encountered time zone problems, nonsense do not say on the code.
Phpdate_default_timezone_set (' PRC ');//Set the default time zone /** * Print the necessary explanatory text*/ Print(<B> a few days from Monday?) </b>\n "); Print("<ol>\n"); for($currentDate= Time();//define $currentdate time format Date("L",$currentDate)! = "Monday";//determine if the current system time is Monday $currentDate+ = (60 * 60 * 24))//Current time plus 1 days { /** * Print time name*/ Print("<li>".Date("Y-m-d h:i:s",$currentDate). " ". " </li>\n "); } Print("</ol>\n");?></body>First, use Date_default_timezone_set () in the header to set my default time zone to GMT
Date_default_timezone_set (' PRC ');
echo Date (' y-m-d h:i:s ');
Time is the same as the current time of the server!!
Second, modify the php.ini.
Open Php5.ini Find Date.timezone Remove the preceding semicolon = Add xxx After, restart HTTP service
(such as apache2 or IIS, etc.).
For XXX, the values available in mainland China are: asia/chongqing, Asia/shanghai,
Asia/urumqi (Chongqing, Shanghai, Urumqi, respectively) Taiwan available: Asia/macao,
Asia/hong_kong, Asia/taipei (Macau, Hong Kong, Taipei) and Singapore:
Asia/singapore foreigners seem to have leaked Beijing. Other available values are: Etc/gmt-8, Singapore,
Hongkong, what is PRC,PRC? PRC is the People's Republic of China Ah-_-above all from the official PHP documentation
Sort out the gmt+8 below the area, there may be omissions.
PHP Time Zone issues