How can I get the timezone name in JavaScript?

后端 未结 8 1605
时光取名叫无心
时光取名叫无心 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条回答
  •  执笔经年
    2020-12-12 15:52

    This gets the timezone code (e.g., GMT) in older javascript (I'm using google app script with old engine):

    function getTimezoneName() {
      return new Date().toString().get(/\((.+)\)/);
    }
    

    I'm just putting this here in case someone needs it.

提交回复
热议问题