Setting the time zone by default does not work even though the time zone is valid

I get when I just do phpinfo ()

Warning: phpinfo (): You cannot rely on the system time zone settings. You must use the date.timezone parameter or the date_default_timezone_set () function. If you used any of these methods and you still get this warning, most likely you are mistaken with the time zone 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:

Note: date_default_timezone_set (): Europe / Kiev timezone ID is not valid in /myadmin/i.php on line 4

I am sure I am using a valid timezone line from here , and I set:

date.timezone = Europe / Kiev

in the php.ini file.

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

I really can’t understand what’s the matter. Thanks.

+6
source share
2 answers

Thanks to the comments, I was able to solve my problem. What I did in the console:

 #yum install php-pear #pecl install timezonedb 

C compiler required:

 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, just 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 
+6
source

To extend the futureboxlab solution, you may encounter another β€œmake” command error if you did not install it. In this case, you just need to run

 #yum install make 

then again (third time charm)

 #pecl install timezonedb 
0
source

Source: https://habr.com/ru/post/905337/


All Articles