Date.getTimezoneOffset

getTimezoneOffset – Get the time-zone offset from UTC, in minutes, for the current locale.

Description

Date.getTimezoneOffset()

Return values

Integer

Examples

Example #1 – Get the local time zone offset.
var date = new Date(); console.log(date.getTimezoneOffset());
Example #2 – You can use this to check for summer / winter time.
var winter = new Date(2000, 0, 1).getTimezoneOffset(); var summer = new Date(2000, 6, 1).getTimezoneOffset(); if (winter === summer) { console.log('Current region does not use dst.'); } else { var now = new Date().getTimezoneOffset(); if (now === winter) { console.log('Currently winter time.'); } else { console.log('Currently summer time.'); } }

A shorter example that will just check if it is currently summer time.

if (new Date().getTimezoneOffset() !== new Date(2000, 0, 1).getTimezoneOffset()) { console.log('Currently summer time.'); } else { // For regions that does not use dst, this will always be the result. console.log('Currently not summer time.'); }

External references