PHP TZ设置长度 [英] PHP TZ setting length

查看:216
本文介绍了PHP TZ设置长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道PHP中时区设置的最大长度是多少?我正在将字符串存储在数据库中,并希望使长度尽可能短,但是我看到诸如"Canada/East-Saskatchewan"之类的时区,超出了我们当前的限制.

I was wonder what is the maximum length of the timezone settings in PHP? I'm storing the string in a database, and would like to keep the length as short as possible, but i see timezones like "Canada/East-Saskatchewan", which goes beyond our current limit.

如果我只能得到所有受支持的时区字符串的列表,则可以对它们进行排序,但是目前它们被分为几个不同的页面.

If I could just get a list of all the supported timezone string, I can sort them, but they are currently split on to several different pages.

链接: http://www.php.net/manual/en/timezones. php

推荐答案

答案是32.下面是完整的PHP代码,用于查找:

Answer is 32. And here is the complete PHP code to find that:

<?php
$timezone_identifiers = DateTimeZone::listIdentifiers();

$maxlen = 0;
foreach($timezone_identifiers as $id)
{
    if(strlen($id) > $maxlen)
        $maxlen = strlen($id);
}

echo "Max Length: $maxlen";

/*
Output:

Max Length: 32

*/
?>

这篇关于PHP TZ设置长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆