![]() |
VOOZH | about |
The date.getTimezoneOffset() method is used to return the time difference between Universal Coordinated Time (UTC) and local time, in minutes. If your time zone is GMT+5, -300 (60*5) minutes will be returned. Daylight savings prevent this value from being constant.
Syntax:
date.getTimezoneOffset()
Parameter: This method does not accept any parameter.
Return Values: It returns a number representing the time difference between UTC and Local Time in minutes.
Below are examples of Date.getTimezoneOffset() method.
Example 1:
Output:
-330
Example 2: The date of the month should lie in between 1 to 31 because none of the months have a date greater than 31 that is why it returns NaN i.e, not a number because the date for the month does not exist.
Output:
NaN
Example 3: In this example, we will leave the new Date blank to get the time difference between UTC and local time by a trigger.
Output:
Note: The Universal Coordinated Time (UTC) is the time set by the World Time Standard. UTC is the same as GMT time.
We have a complete list of Javascript Date Objects, to check those please go through this article.
Supported Browsers: The browsers supported by JavaScript Date getTimezoneOffset() method are listed below:
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through