diff --git a/files/en-us/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html b/files/en-us/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html index 2cec46a1e88983e..dcf533b27f24b71 100644 --- a/files/en-us/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html +++ b/files/en-us/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html @@ -10,7 +10,7 @@ ---
{{JSRef}}
-

The getTimezoneOffset() method returns the time zone difference, in minutes, from current locale (host system settings) to UTC.

+

The getTimezoneOffset() method returns the time-zone difference, in minutes, between UTC time and local time.

{{EmbedInteractiveExample("pages/js/date-gettimezoneoffset.html")}}
@@ -20,13 +20,13 @@

Syntax

Return value

-

A number representing the time-zone offset, in minutes, from the date based on current host system settings to UTC.

+

A number representing the time-zone offset, in minutes, between UTC and local time.

Description

-

The time-zone offset is the difference, in minutes, from local time to UTC.

+

The time-zone offset is the difference, in minutes, between UTC time and local time.

-

Note that this means that the offset is positive if the local timezone is behind UTC, and negative if it is ahead. For example, for time zone UTC+10:00 (Australian Eastern Standard Time, Vladivostok Time, Chamorro Standard Time), -600 will be returned.

+

Note that this means that the offset is positive if the local time zone is behind UTC, and negative if the local time zone is ahead of UTC. For example, for time zone UTC+10:00 (Australian Eastern Standard Time, Vladivostok Time, Chamorro Standard Time), -600 will be returned.

@@ -47,24 +47,20 @@

Description

-

The time zone offset returned is the one that applies for the Date that it's called on.

- -

If the host system is configured for daylight saving, the offset will change depending on the date and time that the Date represents and that daylight saving applies.

+
+

{{jsxref("Date")}} instances do not store a time zone — instead they just store a single value representing the number of milliseconds that have elapsed since midnight on January 1, 1970, UTC — so regardless of what {{jsxref("Date")}} instance the getTimezoneOffset() method is called from, the result isn’t calculated based on the value of the particular {{jsxref("Date")}} instance, but is instead always just the difference between UTC time and local time.

+

Examples

Using getTimezoneOffset()

-
// Get current timezone offset for host device
-let x = new Date();
-let currentTimeZoneOffsetInHours = x.getTimezoneOffset() / 60;
-// 1
-
-// Get timezone offset for International Labour Day (May 1) in 2016
-// Be careful, the Date() constructor uses 0-indexed months, so May is
-// represented with 4 (and not 5)
-let labourDay = new Date(2016, 4, 1)
-let labourDayOffset = labourDay.getTimezoneOffset() / 60;
+
// Create a Date instance for the current time
+let currentLocalDate = new Date();
+// Create a Date instance for 03:24 GMT-0200 on May 1st in 2016
+let laborDay2016at0324GMTminus2 = new Date('May 1, 2016 03:24:00 GMT-0200');
+currentLocalDate.getTimezoneOffset() === laborDay2016at0324.getTimezoneOffset();
+// true, always — no matter of the values of the Date instances
 

Specifications