new Date() method and then we have to add one day to it and it will give us the date of the next day.
const today = new Date() const tomorrow = new Date(today) tomorrow.setDate(tomorrow.getDate() + 1) const tomorrowDate = tomorrow.toDateString() console.log(tomorrowDate)
Fri Jan 07 2022
new Date() : Gives current date and time of the day.
getDate() : It extract the date of the month from the string of new Date().
tomorrow.getDate() + 1 : We extract the date (Eg today is 6 ) and then add 1 to it, so we get 7 (next day date).
setDate() : Allow us to change the day of the month. In the code above, we use setDate() to set the value to 7.
toDateString() : It returns the date in proper format in English.
Using momentJs, we can get the current date in a proper date format by:
So to get tomorrow's date using momentJs we have to add 1 as days :