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的timezone_transitions_get()时发现了一些奇怪的东西。无论使用何种时区,返回数组的第一个元素似乎都是这个不可能/不可用的值:
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?
我已经尝试过PHP 5.3和5.4。它似乎与PECL timezonedb的版本无关。任何人都知道为什么会这样吗?
1 个解决方案
#1
0
Have a look at this documentation for reference of timezone_transitions_get
. Apparently, they are missing the following details:
请查看本文档以获取timezone_transitions_get的参考。显然,他们缺少以下细节:
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.
[ts]值表示转换的时间戳,作为自UTC 1970年1月1日午夜以来的微秒数。它存储为64位有符号整数,-9223372036854775808是可能的最小值。
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.
[time]值是等于[ts]值的ISO8601字符串。对于负面年份来说看起来很有趣,特别是那些有很多数字的数字,但这确实是数学等价物。
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.
[offset]值是转换的UTC偏移量表示的整秒数。除以3600,您将获得相同的小时数。
The [isdst]
value is a boolean (1
or blank) indicating if the offset represents Daylight Saving Time.
[isdst]值是一个布尔值(1或空白),表示偏移量是否代表夏令时。
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.
[abbr]值是描述时区的简短缩写。缩写可能不明确,因此它只是作为显示值存在并且易于参考。什么都不应该被取消。
#1
0
Have a look at this documentation for reference of timezone_transitions_get
. Apparently, they are missing the following details:
请查看本文档以获取timezone_transitions_get的参考。显然,他们缺少以下细节:
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.
[ts]值表示转换的时间戳,作为自UTC 1970年1月1日午夜以来的微秒数。它存储为64位有符号整数,-9223372036854775808是可能的最小值。
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.
[time]值是等于[ts]值的ISO8601字符串。对于负面年份来说看起来很有趣,特别是那些有很多数字的数字,但这确实是数学等价物。
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.
[offset]值是转换的UTC偏移量表示的整秒数。除以3600,您将获得相同的小时数。
The [isdst]
value is a boolean (1
or blank) indicating if the offset represents Daylight Saving Time.
[isdst]值是一个布尔值(1或空白),表示偏移量是否代表夏令时。
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.
[abbr]值是描述时区的简短缩写。缩写可能不明确,因此它只是作为显示值存在并且易于参考。什么都不应该被取消。