Home  >  Article  >  Backend Development  >  How to deal with the warnings encountered when using the Date function in PHP51 and above versions

How to deal with the warnings encountered when using the Date function in PHP51 and above versions

WBOY
WBOYOriginal
2016-07-30 13:30:471029browse

PHP 5.1 and above will encounter this Warning when using the Date function:

"PHP Warning: date() [function.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 means that the time zone in PHP is not set or the function used is wrong!

You can try to find php.ini (the file after configuration) in the PHP installation file, and then Ctrl+F to search for "date.timezone" (it should be the second one if I remember correctly) file), the configuration file shows ";date.timez/span>". This sentence needs to be modified. Remove the previous ;, and then add PRC after =, this It means turning on the time zone function and setting it to China (PRC) time zone!

Finally, be sure to restart the server (Apache, or IIS), and then the problem will be solved !!

Copyright statement: This article is the original article of the blogger and may not be reproduced without the permission of the blogger

.

The above introduces how to deal with the warnings encountered when using the Date function in PHP51 and above versions, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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