I'm using the date-fns library and I have a logic that calculates the time from a given date depending on the number I specify.
For example:
number: 1 month
start date: 01/09/2020
end time: (is calculated automatically according to the code below)
const startDate = new Date("the date that gets 01/09/2020 in this case")
endTime= add(sub(startDate, {seconds: 1}), {months: numberOfPeriods}).toUTCString();
In all months it looks ok, but I have a problem with October, because it gets like an extra 2 hour and then it doesn't calculate it right.
Does anyone have any ideas? I am sending ss from consol which shows calculated endTime