php.ini设立时区,使日期函数不出现warning

WBOY
Release: 2016-06-13 13:25:33
Original
963 people have browsed it

php.ini设置时区,使日期函数不出现warning

php页面对于时间到函数处理出现:

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.

?

?

原因与解决:
? ?这是因为PHP所取的时间是格林威治标准时间,所以和你当地的时间会有出入格林威治标准时间和北京时间大概差8个小时左右,我们可以按照下面的方法解决。

解决办法:

1、在页头使用date_default_timezone_set()设置我的默认时区为北京时间,即


date_default_timezone_set("PRC");

?>就可以了。

2、在php.ini中设置date.timezone的值为PRC,设置好以后的为:date.timezone=PRC,同时取消这一行代码的注释,即去掉前面的分号就可以了。

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!