JavaScript getTimezoneOffset Method





The getTimezoneOffset method returns the difference in minutes between the universal time and the time in the host computer. The value returned by this method is an integer number.


Syntax

myDate.getTimezoneOffset()

With myDate being an object based on the Date object.


Example

The following code uses the getTimezoneOffset method to return the difference in minutes between he universal time and the time in the host computer:

<script type="text/javascript">

var currentTime = new Date();

var differenceToUniversalTime = currentTime.getTimezoneOffset();

document.write("The temporal difference between the universal time and the time in the host computer is " + differenceToUniversalTime + " minutes.");

</script>


Technical Details

The getTimezoneOffset method belongs to the Date object, it is available since the version 1.0 of JavaScript, and it is supported in all major browsers.





JavaScript Manual >> Date Object >> getTimezoneOffset Method





© Copyright 2010-2016 ROM Cartridge