Home >Backend Development >PHP Tutorial >PHP警告date(): It is not safe to rely on the system_PHP教程
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
|
Copy code
|
||||
date_default_timezone_set("PRC"); or ini_set('date.timezone','asiashanghai');
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
The code is as follows |