6

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.

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
Denis
  • 759
  • 1
  • 9
  • 22
  • What does `date_default_timezone_set('Europe/Kiev');` return? It [should](http://nl3.php.net/date_default_timezone_set) return `true` on success and `false` on fail. – Bouke Jan 06 '12 at 18:39
  • Do any other timezones work? Can you try the example given at http://php.net/manual/en/datetimezone.listidentifiers.php to print all supported timezones? – Gordon Jan 06 '12 at 19:14
  • Somehow DateTimeZone::listIdentifiers() returns array(0) { } HOW ? – Denis Jan 06 '12 at 19:23
  • 3
    "The latest version of the timezone database can be installed via PECL's » timezonedb." – malletjo Jan 06 '12 at 19:38
  • 1
    there was some legal issue around the timezone db php uses (Olson DB). However I am not aware of that having any impact on PHP. – Gordon Jan 06 '12 at 20:23
  • @futureboxlab could you move your "solution" section from your question into an answer and mark this question as answered? Thanks! – Jon Jan 09 '12 at 12:19

2 Answers2

7

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
Nicole
  • 32,841
  • 11
  • 75
  • 101
Denis
  • 759
  • 1
  • 9
  • 22
0

To extend futureboxlab's solution, you may encounter another error regarding the 'make' command if you don't have make installed. In that case you'll just need to run

#yum install make

then, once again (third time's the charm)

#pecl install timezonedb
ItsGeorge
  • 2,060
  • 3
  • 17
  • 33