Processing of date () warning reported by the php program (date_default_timezone_set)

Source: Internet
Author: User
PHPWarning: date (): Warning. Youare * required * tousethedate. timezonesettingorthedate_default_timezone_set () function sometimes prompts this warning 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 D: \ PHPWEB ews \ file. php on line 17.

This is because the time taken by PHP is Greenwich mean time, so there will be a difference between the GMT standard time and the Beijing time by about eight hours. we can solve this problem as follows:

1. use date_default_timezone_set () in the page header to set my default time zone to Beijing time, that is You can.

2. in php. set date in ini. the value of timezone is PRC, and the value after setting is date. timezone = PRC or date. timezone = Asia/Shanghai, and cancel the comments of this line of code, that is, remove the semicolon.

Restart apache!

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.