[英]PHP Warning: Unknown: It is not safe to rely on the system's timezone settings
I am getting following error whien i use php -i 我使用php -i时出现以下错误
date
日期
date/time support => enabled "Olson" Timezone Database Version => 0.system Timezone Database => internal PHP Warning: Unknown: It is not safe to rely on the system's timezone settings.
日期/时间支持=>已启用“ Olson”时区数据库版本=> 0.system时区数据库=>内部PHP警告:未知:依靠系统的时区设置并不安全。
You are required to use the date.timezone setting or the date_default_timezon您需要使用date.timezone设置或date_default_timezon
e_set() function.e_set()函数。 In case you used any of those methods and you are still gettin
如果您使用了这些方法中的任何一种,但您仍然可以
g this warning, you most likely misspelled the timezone identifier.在此警告中,您很可能拼错了时区标识符。 We selected
我们选择了
'UTC' for 'UTC/0.0/no DST' instead in Unknown on line 0 Default timezone => UTC“ UTC / 0.0 / no DST”的“ UTC”,而不是第0行的“未知”,默认时区=> UTC
Directive => Local Value => Master Value 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
指令=>本地值=>主值日期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
My /etc/php.ini has following setting 我的/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 version details are as below PHP版本详细信息如下
PHP 5.3.3 (cli) (built: Dec 5 2013 07:09:40) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
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 version as below Apache版本如下
Server version: Apache/2.2.15 (Unix) Server built: Jul 18 2014 02:31:29
服务器版本:Apache / 2.2.15(Unix)服务器内置:2014年7月18日02:31:29
I have restarted Apache multiple times 我已多次重启Apache
更改date.timezone = UTC
然后运行命令sudo service httpd restart
You could use inside of PHP file: 您可以在PHP文件内部使用:
date_default_timezone_set( "YOUR DATE TIME ZONE");
for example: 例如:
date_default_timezone_set( "Europe/Berlin");
List of timezones: http://php.net/manual/en/timezones.php 时区列表: http : //php.net/manual/en/timezones.php
or if you wish to continue using server timezone but want to hide warnings use: 或者,如果您希望继续使用服务器时区,但想隐藏警告,请使用:
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ERROR);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.