[英]PHP Warning: Unknown: It is not safe to rely on the system's timezone settings
我使用php -i時出現以下錯誤
日期
日期/時間支持=>已啟用“ Olson”時區數據庫版本=> 0.system時區數據庫=>內部PHP警告:未知:依靠系統的時區設置並不安全。
您需要使用date.timezone設置或date_default_timezon
e_set()函數。 如果您使用了這些方法中的任何一種,但您仍然可以
在此警告中,您很可能拼錯了時區標識符。 我們選擇了
“ UTC / 0.0 / no DST”的“ UTC”,而不是第0行的“未知”,默認時區=> UTC指令=>本地值=>主值日期date.default_latitude => 31.7667 => 31.7667 date.default_longitude => 35.2333 => 35.2333 date.sunrise_zenith => 90.583333 => 90.583333 date.sunset_zenith => 90.583333 => 90.583333 date.timezone => America / Los_Angeles => America / Los_Angeles
我的/etc/php.ini具有以下設置
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = America/Los_Angeles
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.default-latitude
;date.default_latitude = 31.7667
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.default-longitude
;date.default_longitude = 35.2333
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.sunrise-zenith
;date.sunrise_zenith = 90.583333
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.sunset-zenith
;date.sunset_zenith = 90.583333
PHP版本詳細信息如下
PHP 5.3.3(cli)(內置:2013年12月5日07:09:40)版權所有(c)1997-2010 The PHP Group Zend Engine v2.3.0,版權所有(c)1998-2010 Zend Technologies
Apache版本如下
服務器版本:Apache / 2.2.15(Unix)服務器內置:2014年7月18日02:31:29
我已多次重啟Apache
更改date.timezone = UTC
然后運行命令sudo service httpd restart
您可以在PHP文件內部使用:
date_default_timezone_set( "YOUR DATE TIME ZONE");
例如:
date_default_timezone_set( "Europe/Berlin");
時區列表: http : //php.net/manual/en/timezones.php
或者,如果您希望繼續使用服務器時區,但想隱藏警告,請使用:
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ERROR);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.