I need to increment a date value by one day in JavaScript.
For example, I have a date value 2010-09-11 and I need to store the date of the next day in a JavaScript v
I feel that nothing is safer than .getTime()
and .setTime()
, so this should be the best, and performant as well.
const d = new Date()
console.log(d.setTime(d.getTime() + 1000 * 60 * 60 * 24)) // MILLISECONDS
.setDate()
for invalid Date (like 31 + 1) is too dangerous, and it depends on the browser implementation.