Home >>JavaScript Date Object Methods >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()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
getTimezoneOffset() | Yes | Yes | Yes | Yes | Yes |
<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>
<html> <body> <script> var date=new Date('Aug 45 2019 7:15'); var y=date.getTimezoneOffset(); document.write(y) </script> </body> </html>