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

      <legend id='k5Cbs'><style id='k5Cbs'><dir id='k5Cbs'><q id='k5Cbs'></q></dir></style></legend>

      如何在 JavaScript 中获取时区名称?

      时间:2023-10-11

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

                <tbody id='XR9kr'></tbody>

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

              <tfoot id='XR9kr'></tfoot>
                <bdo id='XR9kr'></bdo><ul id='XR9kr'></ul>
                本文介绍了如何在 JavaScript 中获取时区名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我知道如何获取时区偏移量,但我需要的是能够检测美国/纽约"之类的内容.这甚至可以通过 JavaScript 实现,还是我必须根据偏移量来猜测?

                I know how to get the timezone offset, but what I need is the ability to detect something like "America/New York." Is that even possible from JavaScript or is that something I am going to have to guestimate based on the offset?

                推荐答案

                国际化 API 支持获取用户时区,支持在所有当前的浏览器中.

                The Internationalization API supports getting the user timezone, and is supported in all current browsers.

                console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)

                请记住,在一些支持国际化 API 的旧浏览器版本上,timeZone 属性设置为 undefined 而不是用户的时区字符串.据我所知,在撰写本文时(2017 年 7 月)除 IE11 之外的所有当前浏览器 都会将用户时区作为字符串返回.

                Keep in mind that on some older browser versions that support the Internationalization API, the timeZone property is set to undefined rather than the user’s timezone string. As best as I can tell, at the time of writing (July 2017) all current browsers except for IE11 will return the user timezone as a string.

                这篇关于如何在 JavaScript 中获取时区名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 Nodejs 中使用时区偏移? 下一篇:使用 JavaScript 检测时区缩写

                相关文章

                最新文章

                1. <small id='jJkyw'></small><noframes id='jJkyw'>

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