Cannot Set date.timezone In php.ini file(无法在 php.ini 文件中设置 date.timezone)
问题描述
我正在使用 php5.5,每当我在 PHP 中使用日期函数时都会出现此错误:
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
所以我将 date.timezone 设置更改为:
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
然后我重启服务器:
sudo /etc/init.d/apache2 restart
但仍然出现此错误,我尝试检查附加 ini 文件位置中的 .ini 文件,但没有一个覆盖 date.timezone 设置
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
我已经检查了 php.ini 文件的权限,但还是不行请指导我解决这个问题,谢谢..
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
在这里修改了 date.timezone 但它不起作用.
modified the date.timezone here but it's not working.
因此,我检查了 phpinfo() 中的扫描此目录以获取其他 .ini 文件"值,该值指向:
So, I check the "Scan this dir for additional .ini files " values in phpinfo() which point to:
/etc/php5/apache2/conf.d
然后我从该文件夹中的所有文件中搜索 date.timezone 但没有找到.
then I search date.timezone from all files in that folder but found none.
这是我在 phpinfo() 中的附加 .ini 文件解析值:
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
我修改了/etc/php5/apache2/conf.d/20-xdebug.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 !!!
这篇关于无法在 php.ini 文件中设置 date.timezone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法在 php.ini 文件中设置 date.timezone


- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Laravel 仓库 2022-01-01