加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP生成的时区列表不完整

发布时间:2020-12-13 21:41:19 所属栏目:PHP教程 来源:网络整理
导读:我已经尝试使用以下代码生成 http://php.net/manual/en/timezones.php中指定的完整时区(UTC除外): $zones = timezone_identifiers_list();print_r($zones); 但是这个列表似乎跳过了大约50个地区,例如:太平洋/萨摩亚(与http://php.net/manual/en/timezones.
我已经尝试使用以下代码生成 http://php.net/manual/en/timezones.php中指定的完整时区(UTC除外):

$zones = timezone_identifiers_list();

print_r($zones);

但是这个列表似乎跳过了大约50个地区,例如:太平洋/萨摩亚(与http://php.net/manual/en/timezones.php相比)

我们做错了什么?

phpinfo()显示:

PHP Version 5.3.4
Apache Version  Apache/2.2.3 (CentOS) 

$uname -r
2.6.18-028stab070.14

编辑#2

date
date/time support   enabled
"Olson" Timezone Database Version   0.system
Timezone Database   internal
Default timezone    UTC

解决方法

您的时区数据库可能不是最新的.

请尝试按照List of Supported Timezones页面底部的链接进行操作:

The latest version of the timezone
database can be installed via PECL’s ?
07001.

在评论后编辑:要更新您的时区数据库,就像在Linux系统上一样,您可以使用pecl命令(我刚刚在我的Ubuntu机器上尝试过这个):

pecl upgrade timezonedb

这将下载新版本并进行编译.

然后,如果启用新的timezonedb扩展,则PHP应使用uptodate数据库:

php -dextension=timezonedb.so -i | grep Timezone
"Olson" Timezone Database Version => 2011.5
Timezone Database => external
Alternative Timezone Database => enabled
Timezone Database Version => 2011.5

如果我尝试没有启用新的扩展,我会得到你以前的那种东西:

php -i | grep Timezone
"Olson" Timezone Database Version => 0.system
Timezone Database => internal

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读