Php prompts PHP Warning: date (): It is not safe to rely on the... solution to the error

Source: Internet
Author: User

Sometimes the following warning occurs when writing a php program:

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 PHP gets the Greenwich Mean Time by default, so this time will be 8 hours different from the standard Beijing time. We can solve this problem using the following method:

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

For details about the time zone list, refer to the solution for 8 hours of date difference in php.

2. In the server configuration file php. set date in ini. the value of timezone is PRC, and the value after setting is date. timezone = PRC, remove the semicolon above, that is, cancel the comments of this line of code.

Tip: date_timezone_set-alias DateTime: setTimezone ()

Articles you may be interested in
  • Php prompts Maximum execution time of 30 seconds exceeded... solution to the error
  • PhpMyAdmin Cannot start session without errors error Solution
  • Php prompts Call to undefined function curl_init () Error Solution
  • Select into from prompt Undeclared variable... solution to the error
  • Solution to the DedeTag Engine Create File False error in dedeCMS
  • Solution to the error "event is not defined" prompt in Firefox
  • Fatal error Class 'soapclient' not found in... troubleshooting method
  • The progress bar of XDebug stops at 57%, prompting you to solve the waiting for XDebug session error.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.