Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

94
Vistas
how to calculate timezone offset from given timezone

I have a case where I am trying to calculate timezoneOffset from selected timezone.

The sample I am saving the time in the database as UTC format, Now I am calculating the timezone as per user's location/timezone and setting the timezone offset.

How I can create mapping that -330 offset if from which timezone, I want to calculate it for all the timezone. Example [{ timezone: 'Australia/Sydney', offset: '660' }] and so on..

such that I can search for -330 offset is for which timeozne.

Suppose -330 offset if for which timezone? Where I can create mapping with offset and timezone.

Example User a is from Australia/Sydney then how can I check timezone offset from UTC?

Just a note that I have multiple timezones to support overall more than 30 time zones.

And I want something very accurate calculation.

I know momentjs using it I can do, but suddenly don't know-how.

with momentjs I get UTCoffser of Australia/Sydney //660

Can anyone help me derive the accurate date here?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you have the IANA name for your timezone, you can pass it into Intl.DateTimeFormat and filter out and calculate the offset:

const getUTCOffset = timezone => Intl.DateTimeFormat([], {timeZone: timezone, timeZoneName: 'shortOffset'}).formatToParts().find(o => o.type === 'timeZoneName').value.match(/\-?\d+/)[0]*60;
console.log(getUTCOffset('Australia/Sydney'))


If you're running this code in the user's browser and want to use the user's timezone, then it's even simpler:

new Date().getTimezoneOffset()
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda