• <tfoot id='fK8Ol'></tfoot>

    • <bdo id='fK8Ol'></bdo><ul id='fK8Ol'></ul>
    <i id='fK8Ol'><tr id='fK8Ol'><dt id='fK8Ol'><q id='fK8Ol'><span id='fK8Ol'><b id='fK8Ol'><form id='fK8Ol'><ins id='fK8Ol'></ins><ul id='fK8Ol'></ul><sub id='fK8Ol'></sub></form><legend id='fK8Ol'></legend><bdo id='fK8Ol'><pre id='fK8Ol'><center id='fK8Ol'></center></pre></bdo></b><th id='fK8Ol'></th></span></q></dt></tr></i><div id='fK8Ol'><tfoot id='fK8Ol'></tfoot><dl id='fK8Ol'><fieldset id='fK8Ol'></fieldset></dl></div>
  • <legend id='fK8Ol'><style id='fK8Ol'><dir id='fK8Ol'><q id='fK8Ol'></q></dir></style></legend>

      <small id='fK8Ol'></small><noframes id='fK8Ol'>

        在Javascript中获取时区的UTC偏移量

        时间:2023-10-11
        <legend id='TuJlS'><style id='TuJlS'><dir id='TuJlS'><q id='TuJlS'></q></dir></style></legend>
        <tfoot id='TuJlS'></tfoot>
          <tbody id='TuJlS'></tbody>

        <small id='TuJlS'></small><noframes id='TuJlS'>

              <bdo id='TuJlS'></bdo><ul id='TuJlS'></ul>

                1. <i id='TuJlS'><tr id='TuJlS'><dt id='TuJlS'><q id='TuJlS'><span id='TuJlS'><b id='TuJlS'><form id='TuJlS'><ins id='TuJlS'></ins><ul id='TuJlS'></ul><sub id='TuJlS'></sub></form><legend id='TuJlS'></legend><bdo id='TuJlS'><pre id='TuJlS'><center id='TuJlS'></center></pre></bdo></b><th id='TuJlS'></th></span></q></dt></tr></i><div id='TuJlS'><tfoot id='TuJlS'></tfoot><dl id='TuJlS'><fieldset id='TuJlS'></fieldset></dl></div>
                  本文介绍了在Javascript中获取时区的UTC偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要一个给定时区的 Javascript 函数,返回当前的 utc 偏移量.

                  I need a Javascript function that given a timezone, returns the current utc offset.

                  例如,theFuncIneed('US/Eastern') -> 240

                  For example, theFuncIneed('US/Eastern') -> 240

                  有什么想法吗?

                  谢谢

                  推荐答案

                  一般来说,这是不可能的.

                  • US/Eastern时区的标识符.(它实际上是 America/New_York 的别名,是真正的标识符.)

                  • US/Eastern is an identifier for a time zone. (It's actually an alias to America/New_York, which is the real identifier.)

                  240 是一个时区偏移量.它通常写成 -04:00(反转符号,除以 60).

                  240 is a time zone offset. It's more commonly written as -04:00 (Invert the sign, divide by 60).

                  美国东部时区由东部标准时间和东部夏令时间组成,东部标准时间具有 -05:00 的偏移量,东部夏令时间具有-04 的偏移量:00.

                  The US Eastern Time Zone is comprised of both Eastern Standard Time, which has the offset of -05:00 and Eastern Daylight Time, which has the offset of -04:00.

                  所以说 US/Eastern = 240 一点也不准确.请阅读 timezone 标签wiki,尤其是标题为Time Zone != Offset"的部分.

                  So it is not at all accurate to say US/Eastern = 240. Please read the timezone tag wiki, especially the section titled "Time Zone != Offset".

                  现在您确实要求 当前 偏移量,这 可能的.如果您提供日期+时间参考,则可以解决此问题.

                  Now you did ask for the current offset, which is possible. If you supply a date+time reference, then you can resolve this.

                  • 对于执行 javascript 代码的计算机的本地时区,这是使用 .getTimeZoneOffset() 内置于任何 Date 实例的对象.

                  • For the local time zone of the computer where the javascript code is executing, this is built in with .getTimeZoneOffset() from any instance of a Date object.

                  但如果您希望它用于特定时区,那么您将需要使用 我在此处列出的库之一.

                  But if you want it for a specific time zone, then you will need to use one of the libraries I listed here.

                  这篇关于在Javascript中获取时区的UTC偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何将 IST 时区对象添加到 Moment.js 下一篇:以小时为单位获取时区差异

                  相关文章

                  最新文章

                2. <legend id='cLDDR'><style id='cLDDR'><dir id='cLDDR'><q id='cLDDR'></q></dir></style></legend>

                    <bdo id='cLDDR'></bdo><ul id='cLDDR'></ul>

                3. <small id='cLDDR'></small><noframes id='cLDDR'>

                    <tfoot id='cLDDR'></tfoot>
                      <i id='cLDDR'><tr id='cLDDR'><dt id='cLDDR'><q id='cLDDR'><span id='cLDDR'><b id='cLDDR'><form id='cLDDR'><ins id='cLDDR'></ins><ul id='cLDDR'></ul><sub id='cLDDR'></sub></form><legend id='cLDDR'></legend><bdo id='cLDDR'><pre id='cLDDR'><center id='cLDDR'></center></pre></bdo></b><th id='cLDDR'></th></span></q></dt></tr></i><div id='cLDDR'><tfoot id='cLDDR'></tfoot><dl id='cLDDR'><fieldset id='cLDDR'></fieldset></dl></div>