doumiao0498 2013-07-26 03:26
浏览 56
已采纳

从PHP时区转换_get()返回的这个奇怪的值是什么?

I noticed something odd while using PHP's timezone_transitions_get(). The first element of the returned array seems to be this improbable/unuseable value, regardless of the timezone used:

php -r 'print_r(timezone_transitions_get(new DateTimeZone("GMT")));'
Array
(
    [0] => Array
        (
            [ts] => -9223372036854775808
            [time] => -292277022657-01-27T08:29:52+0000
            [offset] => 0
            [isdst] => 
            [abbr] => UTC
        )

)

php -r 'print_r(timezone_transitions_get(new DateTimeZone("US/Pacific")));'
Array
(
    [0] => Array
        (
            [ts] => -9223372036854775808
            [time] => -292277022657-01-27T08:29:52+0000
            [offset] => -25200
            [isdst] => 1
            [abbr] => PDT
        )
...

I've tried this with PHP 5.3 and 5.4. It seems to be independent of the version of PECL timezonedb used as well. Anyone know why this is happening?

  • 写回答

1条回答 默认 最新

  • doutizhou5312 2013-07-26 20:41
    关注

    Have a look at this documentation for reference of timezone_transitions_get. Apparently, they are missing the following details:

    The [ts] value represents the timestamp of the transition, as the number of microseconds since Midnight Jan 1 1970 UTC. It is stored as a 64-bit signed integer, which -9223372036854775808 is the smallest possible value.

    The [time] value is the ISO8601 string equivalent of the [ts] value. It looks funny for negative years, especially ones with that many digits, but that is indeed the mathematical equivalent.

    Think of these as the "beginning of time". Well, at least as far as computers are concerned. :-)

    The [offset] value is the number of whole seconds represented by the UTC offset of the transition. Divide by 3600 and you will get an equivalent number of hours.

    The [isdst] value is a boolean (1 or blank) indicating if the offset represents Daylight Saving Time.

    The [abbr] value is a short abbreviation describing the time zone. Abbreviations can be ambiguous, so it's just there as a display value and for easy reference. Nothing should be keyed off of it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办