Sometimes, we want to get the time zone name in JavaScript.
In this article, we’ll look at how to get the time zone name in JavaScript.
How to get the time zone name in JavaScript?
To get the time zone name in JavaScript, we can use the DateTimeFormat constructor.
For instance, we write
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)
to call resolvedOptions on the DateTimeFormat object and get the timeZone property to get the device’s current time zone.
Conclusion
To get the time zone name in JavaScript, we can use the DateTimeFormat constructor.