本文介紹了使用 JavaScript 檢測時區縮寫的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我需要一種方法來檢測給定日期對象的時區.我不想要偏移量,也不想要完整的時區名稱.我需要獲取時區縮寫.
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.
例如,GMT、UTC、PST、MST、CST、EST 等...
For example, GMT, UTC, PST, MST, CST, EST, etc...
這可能嗎?我得到的最接近的是解析 date.toString()
的結果,但即使這樣也不會給我縮寫.它給了我時區的長名稱.
Is this possible? The closest I've gotten is parsing the result of date.toString()
, but even that won't give me an abbreviation. It gives me the timezone's long name.
推薦答案
如果一切都失敗了,您可以簡單地使用 長名稱和縮寫.
If all else fails, you can simply create your own hashtable with the long names and abbreviations.
這篇關于使用 JavaScript 檢測時區縮寫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!