browser time

  • time in the browser comes from the Date module
  • to find the timezone
  • they are currently working on the Temporal module to replace this janky legacy
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
console.log('timezone', tz)
  • to find the timezone offset from GMT
const offset = new Date().getTimezoneOffset()
console.log('tz offset', offset)
  • to get local time in hours
const horas = new Date().getHours()
horas < 19 && horas > 7 ? console.log("it's day") : console.log("it's night")

Cited in

browser time