Below is the example of Date getTimezoneOffset() method.
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.
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.
More codes for the above method are as follows:
Program 1: 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.
Program 2: In this example we will leave the new Date blank to get the time difference between UTC and local time by a trigger.
Note: The Universal Coordinated Time (UTC) is the time set by the World Time Standard. UTC is the same as GMT time.
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Internet Explorer 5 and above
- Opera 3 and above
- Safari 1 and above