JavaScript Date getTimezoneOffset()
Example
Get the difference between UTC time and local time:
const d = new Date();
let diff = d.getTimezoneOffset();
Try it Yourself »
Description
getTimezoneOffset()
returns the difference between UTC time and local time.
getTimezoneOffset()
returns the difference in minutes.
For example, if your time zone is GMT+2, -120 will be returned.
Notes
The value is not constant because of varying Daylight Saving Time.
The Universal Time Coordinated (UTC) is the time set by the World Time Standard.
UTC time is the same as GMT (Greenwich Mean Time).
Syntax
Date.getTimezoneOffset()
Parameters
NONE |
Return Value
Type | Description |
A number | The time difference between UTC and Local Time in minutes. |
Browser Support
getTimezoneOffset()
is an ECMAScript1 (JavaScriopt 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |