Solution to PHP Error Prompt It is not safe to rely on the system …

  • 2021-12-04 18:17:59
  • OfStack

Warnings like this sometimes appear in php program development:

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......

We can initially know that it is a time zone problem because the default time obtained by PHP is Greenwich Mean Time, so this time will be 8 hours different from the standard Beijing Time. We can choose one of the following two methods to solve this error.

1. Use the date_default_timezone_set('PRC') Set the time zone to Beijing time.

2. Set the value of date. timezone to PRC in the server PHP configuration file php. ini; Find date.timezone=PRC, remove the semicolon in front of it, that is, cancel the comment of this line of code. If there is no such sentence, you can add it yourself, and then restart the web server.

For the knowledge of PHP time, please refer to the detailed explanation of PHP time function

Summarize


Related articles: