我只是在做 phpinfo() 时得到的
I'm geting when I just do phpinfo()
警告:phpinfo():依赖系统的时区设置是不安全的.您需要使用 date.timezone 设置或 date_default_timezone_set() 函数.如果您使用了这些方法中的任何一种,但仍然收到此警告,您很可能拼错了时区标识符.我们在第 8 行的/myadmin/i.php 中为EET/2.0/no DST"选择了Europe/Helsinki"
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 'Europe/Helsinki' for 'EET/2.0/no DST' instead in /myadmin/i.php on line 8
这里是 i.php:
<?php
//echo date_default_timezone_get();
date_default_timezone_set("Europe/Kiev");
//echo date("l");
phpinfo();
?>
如您所见,当我执行 date_default_timezone_set("Europe/Kiev") 时,我得到:
And as you can see, when I do date_default_timezone_set("Europe/Kiev") I get:
注意:date_default_timezone_set():时区 ID 'Europe/Kiev' 在/myadmin/i.php 第 4 行无效
Notice: date_default_timezone_set(): Timezone ID 'Europe/Kiev' is invalid in /myadmin/i.php on line 4
我确定我使用的是来自 here,我确实设置了:
I'm sure I'm using valid timezone string from here, and I did set :
date.timezone = 欧洲/基辅
date.timezone = Europe/Kiev
在 php.ini 文件中.
in php.ini file.
环境:CentOS 6,nginx/1.1.11,PHP 5.3.8 (fpm-fcgi)
Environment: CentOS 6 , nginx/1.1.11 , PHP 5.3.8 (fpm-fcgi)
我真的不明白这是怎么回事.谢谢.
I really can't understand what's a matter. Thank you.
感谢评论,我能够解决我的问题.我在控制台中做了什么:
Thanks to the comments, I was able to solve my problem. What I've done, in console:
#yum install php-pear
#pecl install timezonedb
需要c编译器:
configure: error: no acceptable C compiler found in $PATH
...所以我做了:
#yum install gcc
另外,如果您收到有关 make 命令的错误,只需运行
Also, if you get an error about the make command, simply run
#yum install make
最后,再试一次:
#pecl install timezonedb
...它显示在末尾:
You should add "extension=timezonedb.so" to php.ini
我将extension=timezonedb.so"添加到/etc/php.ini,并重启了php-fpm:
I added "extension=timezonedb.so" to /etc/php.ini, and restarted php-fpm:
#/etc/init.d/php-fpm restart
这篇关于尽管时区有效,但设置默认时区不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!