getTimezoneOffset Method (Date)

getTimezoneOffset Method (Date) (JavaScript)


Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC).


The required dateObj reference is a Date object.

Returns the number of minutes between the time on the current computer (either the client machine or, if this method is called from a server script, the server machine) and UTC. It is positive if the current computer's local time is behind UTC (e.g., Pacific Daylight Time), and negative if the current computer's local time is ahead of UTC (e.g., Japan). If a server in New York City is contacted by a client in Los Angeles on December 1, getTimezoneOffset returns 480 if executed on the client, or 300 if executed on the server.

The following example shows how to use the getTimezoneOffset method.

var date =  new Date();
var minutes = date.getTimezoneOffset();

if (minutes < 0)
    document.write(minutes / 60 + " hours after UTC");
    document.write(minutes / 60 + " hours before UTC");

// Output (for example, where local time is PST): 
7 hours before UTC


Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Applies To: Date Object (JavaScript)

© 2015 Microsoft