How can I get the timezone name in JavaScript?

后端 未结 8 1654
时光取名叫无心
时光取名叫无心 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
    2020-12-12 15:59

    You can use this script. http://pellepim.bitbucket.org/jstz/

    Fork or clone repository here. https://bitbucket.org/pellepim/jstimezonedetect

    Once you include the script, you can get the list of timezones in - jstz.olson.timezones variable.

    And following code is used to determine client browser's timezone.

    var tz = jstz.determine();
    tz.name();
    

    Enjoy jstz!

提交回复
热议问题