Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!