How to add days to current date in Javascript?
Today, I have a task with request: How to add days to current date in Javascript? and here was the code I used:
1 2 3 4 5 6 7 8 | function addDays(dateObj, numDays) { dateObj.setDate(dateObj.getDate() + numDays); return dateObj; } var now = new Date(); //Current date var nextWeek = addDays(now , 7); // Add 7 days alert(nextWeek); // Result |
This is my code. You can consult.
Good luck.