|
| JAVASCRIPT getTimezoneOffset() METHOD
The getTimezoneOffset() method in javascript returns the difference in minutes between the user's computer and GMT (Greenwich Mean Time) time.
The general format is:
dateObject.getTimezoneOffset();
In order to use this getTimezoneOffset() method, you will first have to create a new date object and then use the new date object with the getTimezoneOffset()method.
Example:
<script type="text/javascript">
var tos=new Date(); // creates a new date object
tos=tos.getTimezoneOffset(); // returns the time difference
document.write(tos); // outputs the time difference
</script>
The above will output:
The above is in minutes. Negative means that GMT is number of minutes behind the user's time. Positive means ahead. To get hours, simply divide the above number by 60.
See Also:
|
|