Get tomorrow's date in JavaScript
Question:
How to get tomorrow's date in JavaScript? Answer:
let today = new Date();
let tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
console.log('Today: ' + today);
console.log('Tomorrow: ' + tomorrow);
Description:
The setDate()
method sets the day of the Date object relative to the beginning of the currently set month.
If the dayValue is outside of the range of date values for the month, setDate()
will update the Date object accordingly. For example, if 0 is provided for dayValue, the date will be set to the last day of the previous month. If a negative number is provided for dayValue, the date will be set counting backwards from the last day of the previous month. -1 would result in the date being set to 1 day before the last day of the previous month.
Reference:
setDate() manual
Share "How to get tomorrow's date in JavaScript?"
Related snippets:
- Convert milliseconds to minutes and seconds
- Check if date is valid in JavaScript
- Generate random date with JavaScript
- Generate random date in a range with JavaScript
- Check if date is today
- Get month name from Date in JavaScript
- Get the current date in JavaScript
- Get difference between 2 dates in JavaScript
- Get yesterday's date in JavaScript
- Get tomorrow's date in JavaScript
Tags:
javascript, date, tomorrow, today, add day Technical term:
Get tomorrow's date in JavaScript