gpt4 book ai didi

EEST 时区上的 Javascript 日期函数错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:38:17 26 4
gpt4 key购买 nike

new Date("May 27, 2011, 1:00 pm EEST")

Firebug 响应:

Date {Invalid Date}

这是一个已知的 javascript 错误吗?你如何用日期解释 javascript 中的“东欧夏令时”时区?

例如,我可以将时区更改为 +03:00 或 +0300,但这样对用户来说就不那么友好了,因为我使用 < abbr > 标记并使用 jQuery 我将每个 abbr innerHTML 格式化为什么他们的标题值是,所以当你将鼠标悬停在它上面时,我仍然希望工具提示显示“2011 年 5 月 27 日,东部标准时间下午 1:00”,但在 innerHTML 中我只需要“2011 年 5 月 27 日”

<abbr class="timestamp blue" title="May 27, 2011, 1:00 pm EEST">May 27, 2011</abbr>

但是,由于 EEST,我明白了

<abbr class="timestamp blue" title="May 27, 2011, 1:00 pm EEST">NaN</abbr>

如果我将 EEST 更改为更常见的东西,例如 EST 或 GMT,那么没问题,很奇怪。

最佳答案

From the ECMA-script specification (15.9.1.15 日期时间字符串格式):

There exists no international standard that specifies abbreviations for civil time zones like CET, EST, etc. and sometimes the same abbreviation is even used for two very different time zones. For this reason, ISO 8601 and this format specifies numeric representations of date and time.

来自 ISO 8601

There are no time zone designators in ISO 8601. Time is only represented as local time or in relation to UTC

简而言之:这不是错误。您不能在 javascript Date 对象中使用 EEST 等区域。您必须坚持使用“UTC”或 +/- 符号。

你可以找到很多关于这个主题的信息@this webpage

关于EEST 时区上的 Javascript 日期函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6149955/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com