I'm working on a site that makes heavy use of time zones which needs to be on the bleeding edge of the absolute latest tz information available (which I already get through the tz mailing list). What I don't know is how to get the PHP installations running on my development machine and my web host to use more up-to-date tz data instead of the older data already on them. This isn't as simple as just upgrading PHP, since even the newest versions of PHP won't necessarily have the absolute latest tz data at any given time.
It's been pointed out that the timezonedb package in pecl
will get me to the latest official release of the package, but what if I need to go a little further to get to that "bleeding edge" of updates that may not have been officially released yet? I'm pretty sure that the newer tz data would have to be compiled with zic
(distributed in tzcode), and the resulting binaries given to pecl
. I really don't know all that this entails, so insight/links for individual steps would be appreciated.
How can one upgrade this Olson database that is used natively by one's instances of PHP on (1) a XAMPP development machine and/or (2) a typical shared hosting service... while jumping through as few hoops and administrative hurdles as possible? Are there any particulars which a shared hosting environment might make more difficult that one should be aware of? Is it feasible to have multiple copies of the data present so that changes could easily be undone if one somehow screws them up?
Since changes sometimes aren't officially released in time for them to take effect, I'm looking specifically for a way to be able to make these changes arbitrarily on my own. I'm also interested in exploring potential tradeoffs over a range of possible solutions from "quick/easy" to "rigorous/best".
Definitive Answer
The comments above give a much better answer than this - look at the PECL package timezonedb
.
I've converted this to Community Wiki.
An Investigation
The distributed source from a package such as php-5.3.8.tar.bz2
contains a translation of the Olson database in the ext/date/lib
directory and files timezonedb.h
, timezonemap.h
, fallbackmap.h
. This means that there is code somewhere in the PHP development system that generates this information from a release of the Olson database, but it is not distributed by default. Further, it is not self-evidently distributed as part of SVN; I extracted PHP 5.3 source as of revision 321876 and the ext/date
directory contained nothing to assist (just the generated files).
So, it might be appropriate to ask the PHP maintainers how to do it; it certainly should be possible, and it should be automated (it would be silly if they do not have it automated). But it is not clear to me that those outside the PHP maintainers can tell how to do it.
The comments in the NEWS file indicate that Derick Rethans might be a good person to contact - he updated the database to Olson 2010c (2010.3). You can find his email address at PHP in the run-tests.php
file in the top-level of the source directory; you can find an alternative email address in the source in ext/date/lib
directory.
Derick Rethans made available the conversion tool kit used to generate the file timezonedb.h
from the Olson database here:
http://svn.xdebug.org/cgi-bin/viewvc.cgi/timelib/trunk/zones/?root=php
As of 2016-12-09, the link above is 404, and the WayBack Machine at the Internet Archive can't help because it was not allowed to search by a robots.txt
file.
However, a Google search for 'php timelib' finds:
which is almost certainly the replacement.
来源:https://stackoverflow.com/questions/8771316/upgrading-olson-tz-database-natively-implemented-in-php