Date getTimezoneOffset() Method - Javascript Date

Javascript examples for Date:getTimezoneOffset

Description

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

For example, If your time zone is GMT+2, -120 will be returned.

UTC time is the same as GMT time.

Parameters

None

Return Value:

A Number, representing the time difference between UTC and Local Time, in minutes

The following code shows how to return the timezone difference between UTC and Local Time:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from w w w .ja va 2 s .  c  om
    var d = new Date();
    var n = d.getTimezoneOffset();
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials