Home >>JavaScript Date Object Methods >JavaScript getTimezoneOffset() Method

JavaScript getTimezoneOffset() Method

JavaScript getTimezoneOffset() Method

The getTimezoneOffset() method is an inbuilt method in JavaScript which is used to returns the time difference between UTC time and local time, in minutes. For example, if your time zone is GMT+6, -360 (60*6) minutes will be returned. The returned value is not a constant, because Daylight saving time prevents this value from being a constant.

Syntax:
Date.getTimezoneOffset()

Browser Support

Method Chrome Edge Firefox Safari Opera
getTimezoneOffset() Yes Yes Yes Yes Yes
Here is an Example of JavaScript getTimezoneOffset() Method:
<html>
<body>
<button onclick="mygetZone()">click me</button>
<p id="Timezone"></p>
<script>
function mygetZone() 
{
  var d = new Date();
  var z = d.getTimezoneOffset();
  document.getElementById("Timezone").innerHTML = z;
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script> 
  var date=new Date('Aug 45 2019 7:15'); 
  var y=date.getTimezoneOffset(); 
  document.write(y) 
</script> 
</body>
</html>
Output:

No Sidebar ads