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

108
Vistas
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 Respuestas
Responde la pregunta

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 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