[英]how to know the timezone name from utc time offset in javascript
How to know the timezone name from UTC offset in Javascript.如何从 Javascript 中的 UTC 偏移量知道时区名称。
I have UTC offset, say我有UTC偏移量,说
UTC+5:30,
I need to know where this timezone location is, like I want to get 'Asia/Calcutta'.
我需要知道这个时区的位置,就像我想得到
'Asia/Calcutta'.
If I give ' UTC+9
' , then I need to get Asia/Tokyo
如果我给 '
UTC+9
' ,那么我需要得到Asia/Tokyo
How to do this in Javascript?如何在 Javascript 中做到这一点?
You should be able to get that using Intl
API.您应该能够使用
Intl
API 获得它。 You can find the demo at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions您可以在https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions找到演示
你可以试试:
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.