How can I get the timezone name in JavaScript?

后端 未结 8 1652
时光取名叫无心
时光取名叫无心 2020-12-12 15:37

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 somethi

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 16:03

    You can simply write your own code by using the mapping table here: http://www.timeanddate.com/time/zones/

    or, use moment-timezone library: http://momentjs.com/timezone/docs/

    See zone.name; // America/Los_Angeles

    or, this library: https://github.com/Canop/tzdetect.js

提交回复
热议问题