DenoDDeno
Powered by
Bradford1802B
Denoβ€’3y agoβ€’
2 replies
Bradford1802

Dates don't increment correctly

when I run the below function with the specific date 2023-09-30, I get the result of n-1 (for any number > 0), where n is the number of the increment specified.

It is only this specific date that appears to have this issue, if I change the Year, Month and/or Day it works.

function addDay(date, days) {
const newDate = new Date(date);
newDate.setDate(newDate.getDate() + days);
return newDate.toISOString().substring(0,10);
};
console.log(addDay("2023-09-30", 1));
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Timezones in Dates?
leighLleigh / help
3y ago
Dates in Deno KV
vwkdVvwkd / help
7mo ago
Date-fns typings don't work?
CianticCCiantic / help
4y ago