typescript add days to date 1

typescript add days to date

addDays(days : number): Date{
  var futureDate = new Date();
  futureDate.setDate(futureDate.getDate() + days);
  return futureDate;

Here is what the above code is Doing:
1. We are creating a new Date object and assigning it to the variable futureDate.
2. We are using the setDate() method to set the date to the current date plus the number of days we want to add.
3. We are returning the futureDate variable.

Similar Posts