timezone_version_get

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

timezone_version_get 获取 timezonedb 版本

说明

timezone_version_get(): string

返回当前 timezonedb 版本。

参数

此函数没有参数。

返回值

返回格式为 YYYY.incrementstring,比如 2022.2

如果时区数据库版本比较旧(比如不显示今年),然后可以通过升级 PHP 版本或者安装 » timezonedb PECL 包来更新时区信息。

一些系统发行版对 PHP 的日期/时间支持打了补丁,以便使用另一个来源的时区信息。在这种情况下,此函数将会返回 0.system。在这种情况下也建议安装 » timezonedb 包。

示例

示例 #1 获取 timezonedb 版本

<?php
echo timezone_version_get();
?>

以上示例的输出类似于:

2022.2

add a note add a note

User Contributed Notes 2 notes

up
7
Omar
12 years ago
On Ubutu:
If you get 0.system for the version, this means you have the version that PHP shipped with. For a newer version, you must upgrade via the PECL extension (sudo pecl install timezonedb)

http://pecl.php.net/package/timezonedb
up
2
chupaka at gmail dot com
3 years ago
On Ubuntu:
If you get '0.system' for the version, this means PHP is using system version of timezone database. For a newer version, simply upgrade 'tzdata' package without installing any PECL extensions:

sudo apt update
sudo apt install tzdata
To Top