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

282
Vistas
Time zone getting changed after using endOf('quarter') on moment js

I'm using the followiing approach to get the end of a quarter:

function convertToMomentDates(dates) {
  return dates.map((date) => moment(date).tz("Europe/Rome"));
}

function getEndOfQuarter(dates) {
    const lastDate = dates.pop();
  if (!lastDate || !lastDate.isValid()) return null;
    console.log(lastDate.endOf("quarter").format());
    return lastDate.endOf("quarter").format();
}

const dates = [
  "2018-10-01T01:00:00+01:00",
  "2019-01-01T01:00:00+01:00",
];

const endOfQuarterResult = getEndOfQuarter(convertToMomentDates(dates));

console.log(
  endOfQuarterResult ===
    "2019-03-31T23:59:59+01:00"
);

document.getElementById('result').innerHTML = endOfQuarterResult;
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.14/moment-timezone-with-data.min.js"></script>
<div id="result"></div>

I mean I'm using all my dates with +1:00 offset and it gets changed to +2:00 after the endOf function, what would be the correct implementation in order to not change the offset...

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

0

On this case the expected result is ok due accoridng Italy/Rome timezone at the end of march, in this case the end of the last quarter it the offset changes to +2. more infor could be seen on this url: https://www.timeanddate.com/time/zone/italy/rome.

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