Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
497 views
in Technique[技术] by (71.8m points)

php - Setting default timezone does not work despite timezone being valid

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...