PHP date of Function Warning: It is not safe to rely on the system Solution

  • 2021-07-13 04:48:38
  • OfStack

Recently, there are always system email prompts, but I didn't care at first. Later, I kept prompting and looked at it once. Prompt for the following information


PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still gett
ing this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /data0/htdocs/www.qttc.net/function/function.php on line 542

Generally speaking, timezone is not set, and Green +8 hours is used in China, so it needs to be set under 1.

Type 1

Add the following statement to the header of the page


date_default_timezone_set("PRC");

This method has a disadvantage, that is, all pages have to be added

Type 2

Find the line date. timezone in php. ini and change the value to PRC, such as date. timezone = PRC. If you don't have this line, just add it directly. Finally, restart WEB server and PHP.


Related articles: