JavaScript getTimezoneOffset()Method

Date 对象参考手册JavaScript Date Object

Examples

Returns the difference between Greenwich Mean Time and local time:

var d = new Date()
var n = d.getTimezoneOffset();

nOutput:


Try it yourself »

Definition and Usage

The getTimezoneOffset() method returns the difference between Greenwich Mean Time and local time, in minutes.

For example, if the time zone is GMT+2, it will return -120.

Note:Due to the practice of using daylight saving time, the return value of this method is not a constant.

Tip:Coordinated Universal Time, also known as Universal Coordinated Time, World Standard Time, International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).

Note:UTC time is the same as GMT (Greenwich) time.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getTimezoneOffset() method.


Syntax

Date.getTimezoneOffset()

Return Value

Type Description
Number The time difference between local time and GMT time, in minutes.

Technical Details

JavaScript Version: 1.0


Date 对象参考手册JavaScript Date Object

Other Extensions