【发布时间】:2013-12-25 10:42:55
【问题描述】:
我正在使用 php5.5,每当我在 PHP 中使用日期函数时都会出现此错误:
Warning: 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/info.php on line 1
加载的配置文件在这里:
/etc/php5/apache2/php.ini
所以我将 date.timezone 设置更改为:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Jakarta
; http://php.net/date.default-latitude
;date.default_latitude = 31.7667
; http://php.net/date.default-longitude
;date.default_longitude = 35.2333
; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333
; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333
然后我重启服务器:
sudo /etc/init.d/apache2 restart
但仍然出现此错误,我尝试检查附加 ini 文件位置中的 .ini 文件,但没有一个覆盖 date.timezone 设置
我已经检查了 php.ini 文件的权限,但还是不行 请指导我解决这个问题,谢谢..
【问题讨论】:
-
注意:
php-cli的php.ini文件与apache2的php.ini文件不同。我建议将一个符号链接到另一个以使它们保持同步并避免混淆! -
这个会在 debian 上吗?
-
检查 php.ini 中的冲突设置,我有相同的,在我的情况下,在 date.timezone 之前定义的 xdebug 设置导致了这个问题:有关更多详细信息,请参阅:stackoverflow.com/questions/36128558/…