Get the App
SLTechnology News&Howtos  ›  Development  › 

The date () function in PHP warns: what about It is not safe to rely on the system

Shulou Source: shulou.com Published: 2022-06-03 08:51:08 11月15日 Update

Editor to share with you the date () function warning in PHP: what to do with It is not safe to rely on the system? I hope you will get something after reading this article. Let's discuss it together.

Recently, there is always a systematic email prompt. I didn't pay attention to it at first, but then I took a look at it again and again. 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 up, but Green + 8 hours is used in China, so it needs to be set up.

First kind

Add the following statement to the header of the page

Date_default_timezone_set ("PRC")

The drawback of this approach is that all pages have to be added.

The second kind

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. Finally, restart the WEB server and PHP.

After reading this article, I believe you have a certain understanding of "date () function warning in PHP: what to do with It is not safe to rely on the system". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Tips functions what to do articles pages one line constantly information headers hours that is methods more servers knowledge systems shortcomings industries statements Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Docker Huawei vpn Linux