About the processing of php programs that report date of warnings of date_default_timezone_set

  • 2020-10-07 18:35:31
  • OfStack

When writing php programs, there are sometimes warnings like this:

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 likely the identifier selected for '8.0/no DST in D:\PHPWEB ews\ php on line 17.

This is because the time taken by PHP is Greenwich Mean time, so there will be a difference between YOUR local time and Greenwich mean time and Beijing time by about 8 hours. We can solve this problem as follows:

1. Use date_default_timezone_set() in the header to set my default time zone as Beijing time, i.e < ?php date_default_timezone_set("PRC"); ? > Just fine.

2. In php. ini, set the value of ES88en. timezone to PRC, and then set the value to date. timezone=PRC or date. timezone = Asia/Shanghai, and uncomment the first line of code, i.e. remove the semicolon.

Then restart apache!


Related articles: