gpt4 book ai didi

javascript - 使用 moment js 传递时区并获取小时偏移量?

转载 作者:行者123 更新时间:2023-11-28 07:01:34 25 4
gpt4 key购买 nike

我想传递一个三位数的时区字符串,如“GMT”或“EST”,并从中获取“-05:00”等偏移量作为字符串。

Moment 似乎可以处理它,但我找不到方法......

最佳答案

您所询问的此功能已被弃用。蒂姆·伍德 this thread说:

The problem is that Date.prototype.toString returns such different results. That is the only place to get the timezone name (PST, CST, EST, etc). If this method is not returning any timezone information (as is the case with FF10 and IE9, there is no way to get it.

在同一线程中,有些人提到他们如何获取缩写时区并随后将其传递给 moment,但仅限于某些浏览器。

关于javascript - 使用 moment js 传递时区并获取小时偏移量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32099329/

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