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

4

13

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?

Adelaidaadelaide answered 25/8, 2010 at 9:31 Comment(2)
Yes you have to add extension=timezonedb.so in php.ini, otherwise how php would know it needs to use that extension or notAlyssa
sudo pecl install timezonedbAdlar
F
6

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.

Force answered 25/8, 2010 at 13:31 Comment(4)
Hi dwich - are you indicating that if we update PHP itself that should work as well? I would have thought PHP updates are few and far in-between...Adelaidaadelaide
As regarding PECL - Im' not too familiar with the concept - is this a standard built-in part of PHP now?Adelaidaadelaide
@tzmatt7447: If you update PHP, it might contain newer version of TDB, but you can't be sure it's the newest one. There can also be new releases of TDB between regular releases of PHP so again - you can't be sure if you update PHP you'll get the newest TDB and - PHP will not be released just because TDB was updated.Force
I'm not a PECL expert, if you want to try it, search for information about installing it to your OS. We use FreeBSD and the installation is as simple as this (pseudo command): pkg_install pecl-timezonedb. Then restart Apache and you're done.Force
M
6

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.

Milk answered 6/1, 2015 at 21:56 Comment(0)
C
2

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.

Catechist answered 29/4, 2011 at 15:50 Comment(1)
Since 2014.10 version the extension can be downloaded as dll for windows, please refer to pecl.php.net/package/timezonedbAlyssa
I
2

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
Indorse answered 5/10, 2017 at 9:26 Comment(2)
When "pecl upgrade intl" runs it asks for "Specify where ICU libraries and headers can be found [DEFAULT] :" What to add here ?Oberland
Check here for clues: #31085579Indorse

© 2022 - 2024 — McMap. All rights reserved.