Add 1 day to new date js

A simple one!

In JavaScript, you can add 1 day to a date using the setDate() method. Here's an example:

const date = new Date('2023-07-25'); // current date
date.setDate(date.getDate() + 1); // add 1 day
console.log(date); // Output: Wed Jul 26 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

The getDate() method returns the day of the month (1-31), and adding 1 to that value sets the date to the next day.

Alternatively, you can use the setDate() method with the Date constructor:

const date = new Date('2023-07-25');
const tomorrow = new Date(date.getTime() + 24 * 60 * 60 * 1000);
console.log(tomorrow); // Output: Wed Jul 26 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

This method uses the getTime() method to get the timestamp of the current date, adds 24 hours (in milliseconds) to it, and then creates a new Date object from the resulting timestamp.