When using PHP version 5.3 or above, a Warning will be reported as long as time is involved: date(): It is not safe to rely on the system's timezone settings.
It generally means that the timezone is not set. In China, Green + 8 hours is used, so it needs to be set up.
The first type
Add the following statement to the head of the page
The code is as follows
代码如下 |
复制代码 |
date_default_timezone_set("PRC"); 或 ini_set('date.timezone','asiashanghai');
|
|
Copy code
|
date_default_timezone_set("PRC"); or ini_set('date.timezone','asiashanghai');
代码如下 |
复制代码 |
date.timezone = PRC。
|
One disadvantage of this method is that all pages must be added
Second type
| Find the date.timezone line in php.ini and change the value to PRC, such as
Copy code
|
date.timezone = PRC.
If there is no such line, just add it directly. Finally, restart the WEB server and PHP.
Friendly reminder: In fact, from PHP 5.1.0, when using functions such as date(), if the timezone is set incorrectly, E_NOTICE or E_WARNING information will be generated every time the time function is called. And in php5.1.0, the date.timezone option is turned off by default. No matter what php command is used, it is Greenwich Mean Time. However, in PHP5.3, it seems that this will be forcibly thrown out if it is not set. Wrong, to solve this problem, just localize it.
http://www.bkjia.com/PHPjc/632160.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632160.htmlTechArticleWhen using PHP versions above PHP5.3, a Warning will be reported as long as time is involved: date() : It is not safe to rely on the system's timezone settings. Generally speaking, timezone is not set...
|