Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update timezonedb in PHP (updating timezones info)?

phpinfo() shows our system to be using ""Olson" Timezone Database Version 2010.3". I think that is now out of date, but can't locate an authoritative location which can confirm that.

(a) Can I update the timezones info for PHP as a whole? (b) If so, how do I update this? I saw the instructions at http://www.electrictoolbox.com/correct-php-timezone/ where it says that, after installing the appropriate module, it says I have to:

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

Do we need to do that? Shouldn't PHP be automatically using the correct file?

like image 889
tzmatt7447 Avatar asked Aug 25 '10 09:08

tzmatt7447


4 Answers

as far as I know the Timezone DB (TDB) is distributed within PHP itself. Because of that the timezone DB becomes obsolete after some time and you should either update PHP or the TDB to reflect the changes in TDB.

There's a PECL extension which releases new TDB packages which you can download and install and use them in your old PHP installations.

I'm not aware there's a way to update TDB directly in PHP. The PECL extension was created to target this issue.

like image 80
dwich Avatar answered Nov 04 '22 23:11

dwich


It's better just to update your PHP version (specially, if you're wanting to update it on a windows machine, otherwise you have to compile the extension yourself) because as far as i remember the extension isn't Windows-Ready only unix/linux - so if you want to do it on windows you will have to compile it yourself using the VC6 OR VC9 compiler).

So, if you can update your PHP version that would be the fastest solution (it was atleast for me), ofcourse PHP may not have the latest timezone db info but i had to resolve a issue with the timezone db and it was fixed in the later version of PHP that i had. If you're doing it for unix/linux you might as well try the PECL extension i think that might be easier & faster for you then.

like image 32
Zubair1 Avatar answered Nov 05 '22 01:11

Zubair1


The PECL extension is literally the timezone DB. Every time a new version of the DB is released from here, the extension is recompiled with the updated timezone DB.

So, you would actually overwrite the old extension with newly recompiled version and restart your web server; assuming PHP is being used as a module.

like image 3
Erutan409 Avatar answered Nov 05 '22 01:11

Erutan409


To do a complete timezone update (We had problems with incorrect Russia / Moscow timezone):

#for OS - CentOS and MySQL
yum update tzdata
mysql_tzinfo_to_sql /usr/share/zoneinfo
#for PHP
pecl upgrade timezonedb
pecl upgrade intl

#dependencies you may need for the above:
yum install gcc 
yum install gcc-c++
yum install libicu-devel
like image 1
trafalgar Avatar answered Nov 05 '22 01:11

trafalgar