Skip to content Skip to sidebar Skip to footer

How To Get A Specific Future Date In Date Picker

I have some data comprising startdate and enddate. When I edit that data, I want to only allow future dates in enddate datepicker, but that has to be one day greater than the star

Solution 1:

  onEditData(data): void {
    var newdate = this.getNextDayToStartDate(data.startDate);
    this.editData = {
      Name: data.Name,
      startDate: this.getDate(data.startDate),
      endDate: newdate
    }
    this.editDataDialog = true;
  }

Your function to add a day returns a value, yet you continue with the original value. Capturing the returnvalue and using that, solves the issue.

Small sidenote: momentjs is a rather usefull thing for working with dates :) Might want to look in to that ;)

Solution 2:

Add editData.startDate to you method call in your html, that will fix it!

<inputtype="date" [min]="getNextDayToStartDate(editData.startDate)" [(ngModel)]="editData.endDate">

Post a Comment for "How To Get A Specific Future Date In Date Picker"