
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to Detect User Timezone in JavaScript?
To detect the user timezone with the name of the timzone itself, use the Internationalization API. This gives the name of the Timezone in which the user and the browser is being worked on.
Detect Exact Timezone with Name
Example
To get the exact timezone name, we will use the Internationalization API −
<!DOCTYPE html> <html> <body> <h1>Timezone</h1> <p id="test"></p> <script> document.getElementById("test").innerHTML = Intl.DateTimeFormat().resolvedOptions().timeZone; </script> </body> </html>
Output

Get the Timezone (Difference between UTC and local time)
Example
To get the timezone, use the getTimezoneOffset() in JavaScript. This method returns the time difference between UTC time and local time. The difference returned is in minutes.
<!DOCTYPE html> <html> <body> <h1>Timezone</h1> <p id="test"></p> <script> const dt = new Date(); let diffTZ = dt.getTimezoneOffset(); document.getElementById("test").innerHTML = diffTZ; </script> </body> </html>
Output

- Related Articles
- How to Detect User Timezone in PHP?
- How to detect user pressing HOME key in iOS?
- How to detect user inactivity for 5 seconds in iOS?
- How to detect user inactivity for 5 seconds in Android?
- How to detect Android user agent type in general using kotlin?
- How do detect Android user agent type in general?
- How to detect user inactivity for 5 seconds in Android using Kotlin?
- How to detect user pressing Home Key in an Activity on Android?
- How to change MySQL timezone?
- How to detect a mobile device with JavaScript?
- How to detect the screen resolution with JavaScript?
- How to detect that JavaScript Cookies are disabled?
- How to detect all active JavaScript event handlers?
- How to detect if JavaScript is disabled in a browser?
- Simplest way to detect keypresses in JavaScript?

Advertisements