Home  >  Article  >  Backend Development  >  php prompt PHP Warning: date(): It is not safe to rely on the... Error solution_PHP tutorial

php prompt PHP Warning: date(): It is not safe to rely on the... Error solution_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:30:561136browse

Sometimes such a warning will appear when writing PHP programs:

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

This is because the default time obtained by PHP is Greenwich Mean Time, so this time will be 8 hours different from standard Beijing time. We can use the following method to solve this problem:

1. Use date_default_timezone_set('PRC') in the header to set the time zone to Beijing time.

For the specific time zone list, please refer to: Solution to the 8-hour difference in date time in php

2. Set the value of date.timezone to PRC in the server configuration file php.ini. After setting it, it will be: date.timezone=PRC. At the same time, remove the preceding semicolon, that is, uncomment this line of code.

Tips: date_timezone_set — alias DateTime::setTimezone()

Articles you may be interested in

  • php prompts Maximum execution time of 30 seconds exceeded... Error solution Solution
  • phpMyAdmin Cannot start session without errors Error solution
  • php prompt Call to undefined function curl_init() Error solution
  • select into from prompt Undeclared variable... ..The solution to the error
  • The solution to the error prompting DedeTag Engine Create File False in dedeCMS
  • The solution to the error prompting event is not defined in Firefox
  • Fatal error Class 'SoapClient' not found in... Error handling method
  • The progress bar of XDebug stops at 57%, prompting waiting for XDebug session error solution

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764187.htmlTechArticleSometimes such a warning will appear when writing PHP programs: PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setti...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn