问题
How to know the timezone name from UTC offset in Javascript.
I have UTC offset, say
UTC+5:30,
I need to know where this timezone location is, like I want to get
'Asia/Calcutta'.
If I give
'UTC+9
'
, then I need to get
Asia/Tokyo
How to do this in Javascript?
回答1:
You should be able to get that using Intl
API. You can find the demo at
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions
回答2:
You can try that:
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)
来源:https://stackoverflow.com/questions/54473715/how-to-know-the-timezone-name-from-utc-time-offset-in-javascript