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

笑着哭i 提交于 2019-11-27 04:42:46

问题


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?


回答1:


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.




回答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.




回答3:


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.




回答4:


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


来源:https://stackoverflow.com/questions/3564478/how-to-update-timezonedb-in-php-updating-timezones-info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!