如何在 PHP 中更新 timezonedb(更新时区信息)?

2022-01-16 00:00:00 datetime timezone php pecl

phpinfo() 显示我们的系统正在使用Olson"时区数据库版本 2010.3.我认为现在已经过时了,但找不到可以确认的权威位置.

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) 我可以更新整个 PHP 的时区信息吗?(b) 如果是这样,我该如何更新?我在 http://www.electrictoolbox.com/correct-php-timezone/ 它说,在安装了适当的模块后,它说我必须:

(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

我们需要这样做吗?PHP 不应该自动使用正确的文件吗?

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

推荐答案

据我所知,Timezone DB (TDB) 分布在 PHP 本身中.因此,时区数据库会在一段时间后过时,您应该更新 PHP 或 TDB 以反映 TDB 中的更改.

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.

有一个 PECL 扩展,它发布了新的 TDB 包,您可以下载并安装它们并在旧的 PHP 安装中使用它们.

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

我不知道有一种方法可以直接在 PHP 中更新 TDB.创建 PECL 扩展以解决此问题.

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

相关文章