设置默认时区不工作,尽管时区有效 [英] Setting default timezone does not work despite timezone being valid

查看:238
本文介绍了设置默认时区不工作,尽管时区有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我只是做phpinfo()时,我正在进行


警告:phpinfo系统的时区设置。您需要 才能使用date.timezone设置或date_default_timezone_set()函数。如果你使用任何这些方法,你仍然得到这个警告,你很可能拼写时区标识符拼写错误。我们在第8行的/myadmin/i.php中选择EET / 2.0 / no DST的欧洲/赫尔辛基。


这里是i.php:

 <?php 
// echo date_default_timezone_get

date_default_timezone_set(Europe / Kiev);

// echo date(l);

phpinfo();
?>

正如你所看到的,当我做date_default_timezone_set(Europe / Kiev)时, / p>


注意:date_default_timezone_set():时区IDEurope / Kiev在第4行的/myadmin/i.php中无效


我确定我使用的有效时区字符串这里,我设置了:


date.timezone =欧洲/ Kiev




环境:CentOS 6 ,nginx / 1.1.11,PHP 5.3.8(fpm-fcgi)



我真的不明白什么是重要的。
谢谢。

解决方案

感谢评论,我能够解决我的问题。我在控制台中做了什么:

  #yum install php-pear 

#pecl install timezonedb

它需要c编译器:

  configure:error:在$ PATH中找不到可接受的C编译器

...所以我做了:

  #yum install gcc 

此外,
如果您遇到关于make命令的错误,只需运行

  #yum install make 

最后,再试一次:

  #pecl install timezonedb 

...它显示在结尾:

 您应该将extension = timezonedb.so添加到php.ini 



我添加了extension = timezonedb.so到/etc/php.ini,然后重新启动php-fpm:

 #/ etc / init.d / php-fpm restart 


I'm geting when I just do phpinfo()

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

here is i.php :

<?php
//echo date_default_timezone_get();

date_default_timezone_set("Europe/Kiev");

//echo date("l");

phpinfo();
?>

And as you can see, when I do date_default_timezone_set("Europe/Kiev") I get:

Notice: date_default_timezone_set(): Timezone ID 'Europe/Kiev' is invalid in /myadmin/i.php on line 4

I'm sure I'm using valid timezone string from here, and I did set :

date.timezone = Europe/Kiev

in php.ini file.

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

It required c compiler:

configure: error: no acceptable C compiler found in $PATH

...so I did:

#yum install gcc

Also, if you get an error about the make command, simply run

#yum install make

Finally, try again:

#pecl install timezonedb

...it displays at the end:

You should add "extension=timezonedb.so" to php.ini

I added "extension=timezonedb.so" to /etc/php.ini, and restarted php-fpm:

#/etc/init.d/php-fpm restart

这篇关于设置默认时区不工作,尽管时区有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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