PHP summer time off

Posted by 6bytes at 14, August, 2009

Category: Linux, PHP

Problem

PHP has a bug with applying summertime in some timezones. If you’ve set correct timezone in your php.ini file and running

< ?php
echo date("r");
?>

still gives you wrong time its quite possible that you’ve just found this bug.

Solution

To correct this you need to install new timezone file. Run below command on your server:

$ pecl install timezonedb

Successful installation should result in something like this

Build process completed successfully
Installing '/usr/local/lib/php/extensions/debug-non-zts-20060613/timezonedb.so'
install ok: channel://pecl.php.net/timezonedb-2009.10
configuration option "php_ini" is not set to php.ini location
You should add "extension=timezonedb.so" to php.ini

open your php.ini file

$ vim /etc/php.ini

add line “extension=timezonedb.so” as instructed.

If PHP now surprises you with

PHP Warning:  PHP Startup: Unable to load dynamic library './timezonedb.so' - 
./timezonedb.so: cannot open shared object file: No such file or directory in 
Unknown on line 0

you need to add full path to the “timezonedb.so” file in your php.ini
Install process returns the full path to “timezonedb.so” but if you need to find it type:

$ find / -name timezonedb.so

edit your php.ini once more and change

extension=timezonedb.so

to

extension=/path/to/your/php/extensions/timezonedb.so

Done.