getTimezoneOffset Method (Windows Scripting - JScript)

 

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

Syntax

dateObj.getTimezoneOffset() 

Remarks

The required dateObj reference is a Date object.

The getTimezoneOffset method returns an integer value representing the number of minutes between the time on the current machine and UTC. These values are appropriate to the computer the script is executed on. If it is called from a server script, the return value is appropriate to the server. If it is called from a client script, the return value is appropriate to the client.

This number will be positive if you are behind UTC (e.g., Pacific Daylight Time), and negative if you are ahead of UTC (e.g., Japan).

For example, suppose 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 illustrates the use of the getTimezoneOffset method.

function TZDemo()
{
    var d = new Date();
    var minutes = d.getTimezoneOffset();

    var s = "";
    s += "The current local time is ";
    s += minutes / 60;
    if (minutes < 0)
        s += " hours after UTC";
    else
        s += " hours before UTC";
    

    return(s);
}

Requirements

Version 1

Applies To: Date Object (Windows Scripting - JScript)

Change History

Date

History

Reason

September 2009

Modified example.

Information enhancement.

March 2009

Fixed bug in sample code.

Content bug fix.

See Also

getTime Method (Windows Scripting - JScript)