About the processing of date() warning reported by PHP program (date_default_timezone_set)_PHP tutorial

WBOY
Release: 2016-07-13 10:25:55
Original
783 people have browsed it

Sometimes this 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 D:PHPWEB ewsfile.php on line 17 .

This is because the time taken by PHP is Greenwich Mean Time, so it will be different from your local time. The difference between Greenwich Mean Time and Beijing time is about 8 hours. We can solve it according to the following method:

1. Use date_default_timezone_set() on the header of the page to set my default time zone to Beijing time, that is, That's it.

2. Set the value of date.timezone in php.ini to PRC. After setting, it will be: date.timezone=PRC or date.timezone = Asia/Shanghai. At the same time, uncomment this line of code, that is, remove the preceding one. The semicolon is fine.

Then restart apache!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824881.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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template