How does php remove the warning when getting the current date
This article will explain in detail how php removes the warning when getting the current date. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Php gets rid of the warning when getting the current date: 1, set the value of date.timezone to PRC;2 in php.ini, cancel the comments before the date.timezone=PRC code; 3, restart apache.
This article operating environment: windows10 system, php 7, thinkpad T480 computer.
A warning similar to the following may occur when getting the current date:
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 getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for' 8.0/no DST' instead in D:\ PHPWEB ews\ file.php on line 17.
This is because the time taken by PHP is Greenwich mean time, so it will be different from your local time. The difference between Greenwich mean time and Beijing time is about 8 hours. We can solve the problem according to the following methods:
1. Use date_default_timezone_set () in the header to set my default time zone to Beijing time.
2. In php.ini, set the value of date.timezone to PRC, set it to date.timezone=PRC or date.timezone= Asia/Shanghai, and uncomment this line of code, that is, remove the previous semicolon.
Then restart apache.
This is the end of the article on "how to get rid of the warning when getting the current date in php". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.