Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

281
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda