PHP生成的时区列表不完整 [英] Incomplete list of timezones generated by PHP
问题描述
我已经尝试生成完整的时区集,如 http://php.net中指定的那样/manual/en/timezones.php (UTC除外),方法是使用以下代码:
I've tried generating the complete set of timezones as specified in http://php.net/manual/en/timezones.php (except UTC) by using the following code:
$zones = timezone_identifiers_list();
print_r($zones);
但是此列表似乎跳过了约50个区域,例如:Pacific/Samoa(与 http ://php.net/manual/en/timezones.php )
But this list seems to skip ~ 50 regions, eg: Pacific/Samoa (as compared to http://php.net/manual/en/timezones.php)
我们在做什么错了?
phpinfo()显示:
phpinfo() shows:
PHP Version 5.3.4
Apache Version Apache/2.2.3 (CentOS)
$ uname -r
2.6.18-028stab070.14
编辑#2
Edit #2
date
date/time support enabled
"Olson" Timezone Database Version 0.system
Timezone Database internal
Default timezone UTC
推荐答案
您的时区数据库可能不是最新的.
Your timezone database might not be up-to-date.
请尝试点击受支持的时区列表页底部的链接:
Try following the link at the bottom of the List of Supported Timezones page :
时区的最新版本 可以通过PECL的数据库安装» timezonedb .
The latest version of the timezone database can be installed via PECL's » timezonedb.
在注释后以更新您的时区数据库,就像在Linux系统上一样,您可以使用pecl
命令(我刚刚在我的Ubuntu机器上尝试过此操作) :
Edit after the comments : to update your timezone database, as you are on a Linux system, you can use the pecl
command (I just tried this on my Ubuntu machine) :
pecl upgrade timezonedb
这将下载新版本并进行编译.
This will download the new version, and compile it.
然后,如果启用了新的timezonedb
扩展名,则您的PHP应该使用一个最新的数据库:
Then, if you enable the new timezonedb
extension, your PHP should use an uptodate database :
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
如果我尝试不启用该新扩展名,则会得到与以前相同的东西:
If I try without enabling that new extension, I get the same kind of thing you had before :
php -i | grep Timezone
"Olson" Timezone Database Version => 0.system
Timezone Database => internal
这篇关于PHP生成的时区列表不完整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!