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

253
Vistas
How to find future UTC offset based on specific date and time zone name using Angular?

Is there an equivalent for figuring out UTC offset by supplying date, time, time zone name using Angular? This is very easy in C# - example below:

TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("US Eastern Standard Time");

string dateInput = "2022-11-15";
var parsedDate = DateTime.Parse(dateInput);
TimeSpan offset = tzi.GetUtcOffset(parsedDate); // this returns -5

string dateInput2 = "2022-03-20";
var parsedDate2 = DateTime.Parse(dateInput2);
TimeSpan offset2 = tzi.GetUtcOffset(parsedDate2); // this returns -4
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The JavaScript getTimezoneOffset() method is used to find the timezone offset

let d = new Date(Date.parse("2022-03-21T06:38:30+0000"));
console.log(d.getTimezoneOffset()) // 120 minutes offset for me

about 4 years ago · Juan Pablo Isaza Denunciar

0

After many hours spent on this I decided to give moment.js as suggested by Joosep.P to try some library and also by others. The below seems to work as expected. What is bizarre is if you try to use timezoneName other than where you currently are and if you debug, you will still see your own time zone name for the date, however the offset will be calculated correctly. I assume that this works because of proper setting .tz call.

var timezoneName = 'America/New_York';
var dateInput = '2022-11-15';
var parsedDate = moment.tz(dateInput, timezoneName);
var offseta = parsedDate.utcOffset()/60; // this returns -5
var offsetb = moment.tz(dateInput, timezoneName).format('Z'); // returns '-05:00' as a string

var dateInput2 = '2022-03-20';
var parsedDate2 = moment.tz(dateInput2, timezoneName);
var offset2a = parsedDate2.utcOffset()/60; // this returns -4
var offset2b = moment.tz(dateInput2, timezoneName).format('Z'); // returns '-04:00' as a string
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