Categories
JavaScript Answers

How to get the time zone name in JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *