How to add days to current date in Javascript?
by Kiet Huynh · July 16, 2017
Today, I have a task with request: How to add days to current date in Javascript? and here was the code I used:
| 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.
Related
Tags: javascriptprogrammingprogramming tips
You may also like...