increment day date javascript
incrementeDate(dias: any) { var tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + dias); return tomorrow; } const date = incrementeDate(5); // start date: 9/30/21 // result date: 10/05/21
Here is what the above code is Doing:
1. We create a new Date object called tomorrow.
2. We set tomorrow’s date to today’s date plus 5 days.
3. We return tomorrow.
4. We call incrementeDate() with 5 as an argument.
5. We assign the return value to a variable called date.