Detect timezone abbreviation using JavaScript

后端 未结 16 2138
清酒与你
清酒与你 2020-11-30 02:17

I need a way to detect the timezone of a given date object. I do NOT want the offset, nor do I want the full timezone name. I need to get the timezone abbreviation.

16条回答
  •  既然无缘
    2020-11-30 02:48

    moment-timezone includes an undocumented method .zoneAbbr() which returns the time zone abbreviation. This also requires a set of rules which are available to select and download as needed.

    Doing this:

    
    
    
    
    

    Returns:

    'PDT' // As of this posting.
    

    Edit (Feb 2018)

    Evan Czaplicki has worked on a draft proposal to add a time zone API to browsers.

提交回复
热议问题