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

113
Visualizações
addMonths fns is not returning correct UTC time

I'm currently based in Central European Standard Time and I'm expecting to send all dates to the server converted back to UTC.

I have tried simply using addMonths from date-fns library:

import addMonths from "date-fns/addMonths";

const now = new Date();
// Sat Mar 05 2022 13:56:04 GMT+0100 (Central European Standard Time)
console.log(now);
const oneMonthFromNow = addMonths(now, 1);
// 2022-04-05T11:56:04.189Z
console.log(oneMonthFromNow.toISOString());

The difference between CEST and UTC is simply one hour. I'm expecting to have an hour and one month difference between now and oneMonthFromNOw but it ends up having one month and two hours difference.

What I would expect:

import addMonths from "date-fns/addMonths";

const now = new Date();
// Sat Mar 05 2022 13:56:04 GMT+0100 (Central European Standard Time)
console.log(now);
const oneMonthFromNow = addMonths(now, 1);
// Since CEST time is 13:56:04 I would expect to get 12:56:04 (1 hour difference only)
// But I end up getting 2022-04-05T12:56:04.189Z
console.log(oneMonthFromNow.toISOString());

Am I missunderstanding something here? Shouldn't I get one month and one hour difference between now and oneMonthFromNow?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The difference between CEST and UTC is simply one hour.


The difference is two hours: Central European Summer Time (CEST, UTC+02:00).


You went from CET time (one hour ahead) on Mar 05 2022 to CEST summer time (two hours ahead) on 2022-04-05.


Central European Time (CET) is a standard time which is 1 hour ahead of Coordinated Universal Time (UTC).

As of 2011, all member states of the European Union observe summer time (daylight saving time), from the last Sunday in March to the last Sunday in October. States within the CET area switch to Central European Summer Time (CEST, UTC+02:00) for the summer.

Wikipedia: Central European Time

Wikipedia: Central European Summer Time

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