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));
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
D
Deno
Chat about Deno, a modern runtime for JavaScript and TypeScript.