Sometimes, we want to get time zone from user’s browser using moment-timezone and JavaScript.
In this article, we’ll look at how to get time zone from user’s browser using moment-timezone and JavaScript.
How to get time zone from user’s browser using moment-timezone and JavaScript?
To get time zone from user’s browser using moment-timezone and JavaScript, we call the moment.tz.guess
method.
For instance, we write
const tz = moment.tz.guess();
to call moment.tz.guess
to return the time zone of the device the user’s browser is running on as a string.
Conclusion
To get time zone from user’s browser using moment-timezone and JavaScript, we call the moment.tz.guess
method.