Yev*_*yev 4 timezone timezone-offset
php 中的时区是这样工作的https://www.gsp.com/support/virtual/admin/unix/tz/gmt/
当Etc/GMT+11它真正命名它时GMT-11
当Etc/GMT-11它真正命名它时GMT+11
为什么?这是什么意思Etc/GMT?
我在 PHP 中发现它,它是 PHP 中的错误还是无处不在?
这不是一个错误。该表单的 tz 数据库标识符Etc/GMT±*故意采用与我们在 ISO 8601 下预期的通常形式相比的倒号符号。也就是说,它们表示正值位于 GMT 以西,而不是正值位于 GMT 以东。
其原因是用于与POSIX样式时区标识符向后兼容,如与第一格式中使用的TZ环境变量。当符合 POSIX 的系统解释此变量时,值 likeAmerica/Los_Angeles显然会落入第三种格式(在同一文档中描述),但值 likeEtc/GMT+11不明确应应用哪种格式规则。因此,区域标识符必须反转其符号以符合要求。
Run Code Online (Sandbox Code Playgroud)# Be consistent with POSIX TZ settings in the Zone names, # even though this is the opposite of what many people expect. # POSIX has positive signs west of Greenwich, but many people expect # positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses # the abbreviation "-04" and corresponds to 4 hours behind UT # (i.e. west of Greenwich) even though many people would expect it to # mean 4 hours ahead of UT (i.e. east of Greenwich).
维基百科关于 tz 数据库的文章也讨论了这一点。
就实际问题而言,tz 数据库评论中还说:
Run Code Online (Sandbox Code Playgroud)# These entries are mostly present for historical reasons, so that # people in areas not otherwise covered by the tz files could "zic -l" # to a time zone that was right for their area. These days, the # tz files cover almost all the inhabited world, and the only practical # need now for the entries that are not on UTC are for ships at sea # that cannot use POSIX TZ settings.
因此,如果您没有为海上船只留出时间,我强烈建议您改用基于位置的标识符。(也许Australia/Melbourne?)
此外,更好的时区标识符来源是Wikipedia。
既然你说你在使用 PHP,请注意PHP 文档也有一个列表,在“其他”页面上,它实际上也解释了这一点:
警告 请不要使用此处列出的任何时区(UTC 除外),它们仅出于向后兼容的原因而存在,并且可能会暴露错误行为。
警告 如果您无视上述警告,还请注意提供 PHP 时区支持的 IANA 时区数据库使用 POSIX 样式标志,这会导致 Etc/GMT+n 和 Etc/GMT-n 时区与常见用法相反。
例如,在中国和西澳大利亚(以及其他地方)使用的 GMT 前 8 小时的时区在此数据库中实际上是 Etc/GMT-8,而不是您通常期望的 Etc/GMT+8。
再次强烈建议您为您所在的位置使用正确的时区,例如上面示例中的亚洲/上海或澳大利亚/珀斯。
| 归档时间: |
|
| 查看次数: |
1838 次 |
| 最近记录: |