解決 PHP 5.3.0 phpinfo();中的It is not safe to rely on the system’s timezone settings警告


Warning: phpinfo() [function.phpinfo]: 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:\apache2.2\htdocs\index.php on line 2
解决方法:

大多看到这种问题是在您用的是 PHP 5.3.0 或使用套裝软件搭配的 PHP 版本是 5.3.0。

1. 修改 php.ini

找到date.timezone,去掉前面分号,后面增加值:"Asia/Shanghai"

date.timezone = "Asia/shanghai"

上面的Asia/Shanghai 均可以替换成下面任一城市。 其它城市:

日本 : Asia/Tokyo
台北 : Asia/Taipei
重庆 : Asia/Chongqing
汉城 : Asia/Seoul
上海 : Asia/Shanghai
新加坡 : Asia/Singapore
澳门 : Asia/Macao 或 Asia/Macau
香港 : Asia/Hong_Kong 或 Asia/Chungking

2、如果非要使用格林威治时间(服务器外国也在用,中国也在用),那么就单独修改出错的也面:

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

<?php

date_default_timezone_set("PRC");

?>

版权所有:《太阳花工作室》 => 《解決 PHP 5.3.0 phpinfo();中的It is not safe to rely on the system’s timezone settings警告
本文地址:http://bg.artuion.com/linux/181.html
除非注明,文章均为 《太阳花工作室》 原创,欢迎转载!转载请注明本文地址,谢谢。