Get the difference between UTC time and local time:
const d = new Date();
let diff = d.getTimezoneOffset();
Try it Yourself »
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.
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).
Date.getTimezoneOffset()
NONE |
Type | Description |
A number | The time difference between UTC and Local Time in minutes. |
getTimezoneOffset()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!