I was surprised that new Date().getTimezoneOffset() returns the opposite of moment().utcOffset()
Examples:
Question:
If I am correct momentjs is returning the correct value. So why is Javascript new Date().getTimezoneOffset() returning the opposite timezone offset?
The time-zone offset is the difference, in minutes, between UTC and local time. Note that this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead. For example, if your time zone is UTC+10 (Australian Eastern Standard Time), -600 will be returned.
from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With