Javascript - TimeZone


Time - Time Zone in Javascript


Get description

timeZoneDesc = Intl.DateTimeFormat().resolvedOptions().timeZone
console.log("Your time zone is: "+timeZoneDesc)

Get offset

Javascript with getTimezoneOffset(). The method returns the time zone difference (in minutes) from UTC (ie UTC - TimeZone)

offsetMinutes = (new Date()).getTimezoneOffset()
console.log("To go to UTC, you need to add or subtract")
console.log("  * "+offsetMinutes+" minutes" )
console.log("  * "+offsetMinutes/60+" zones")

Powered by ComboStrap