无法设置date.timezone在php.ini文件中 [英] Cannot Set date.timezone In php.ini file

查看:389
本文介绍了无法设置date.timezone在php.ini文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 警告:phpinfo我使用php5.5,并在PHP中使用date函数时收到此错误():依靠系统的时区设置是不安全的。您需要*使用date.timezone设置或date_default_timezone_set()函数。如果您使用任何这些方法,并且您仍然收到此警告,您很可能拼写时区标识符。我们现在选择了时区'UTC',但请设置date.timezone来选择您的时区。在/var/www/info.php第1行

加载的配置文件在这里: p>

  /etc/php5/apache2/php.ini 

所以我将date.timezone设置更改为:

  [Date] 
;定义日期函数
使用的默认时区; http://php.net/date.timezone
date.timezone =亚洲/雅加达

; 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文件,但没有一个覆盖日期。时区设置



我已经检查过php.ini文件的权限,但仍然不能正常工作
请指导我解决这个问题,谢谢..

解决方案

终于解决了我的问题,
这是我的加载配置文件:

  /etc/php5/apache2/php.ini 

修改date.timezone在这里,但它不工作。



所以,我检查了在phpinfo()中指向扫描此目录中的其他.ini文件值:

  /etc/php5/apache2/conf.d 

然后我搜索日期。时区,该文件夹中的所有文件,但找不到。



这是我的附加.ini文件解析的值在phpinfo()中:

  /etc/php5/apache2/conf.d/05-opcache.ini,/etc/php5/apache2/conf.d/10-pdo.ini,/ etc /php5/apache2/conf.d/20-json.ini,/etc/php5/apache2/conf.d/20-mysql.ini,/etc/php5/apache2/conf.d/20-mysqli.ini,/ etc / php5 / apache2 / conf.d / 20-pdo_mysql.ini,/etc/php5/apache2/conf.d/20-xdebug.ini,/etc/php5/apache2/conf.d/30-mcrypt.ini 

我修改了/etc/php5/apache2/conf.d/20-xdebug.ini,并附加了行:

  date.timezone =亚洲/雅加达

非常奇怪,但这解决了我的问题!!!


I'm using php5.5 and getting this error whenever I used the date function in 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

the loaded configuration file is here:

/etc/php5/apache2/php.ini 

so I changed the date.timezone setting into this:

[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

Then I restart the server:

sudo /etc/init.d/apache2 restart

but still getting this error, I tried to check the .ini file in the Additional ini file location but none of it is overriding the date.timezone setting

I've checked the php.ini file permission, but still not working please guide me to solve this problem, thanks..

解决方案

finally solved my problem, this is my Loaded Configuration File:

/etc/php5/apache2/php.ini 

modified the date.timezone here but it's not working.

So, I check the "Scan this dir for additional .ini files " values in phpinfo() which point to:

/etc/php5/apache2/conf.d 

then I search date.timezone from all files in that folder but found none.

this is my Additional .ini file parsed value in phpinfo():

/etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-json.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/20-xdebug.ini, /etc/php5/apache2/conf.d/30-mcrypt.ini 

I modified /etc/php5/apache2/conf.d/20-xdebug.ini, and appended this line:

date.timezone = Asia/Jakarta

very weird but this solved my problem !!!

这篇关于无法设置date.timezone在php.ini文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆