Ionic set Max date to 6 days later


#1

How to set max date on ionic to 1 week from today.
Example: if today is 01-01-2018, I wan to set max date to 07-01-2018
I try with this one on my .ts and I got error.
public maxDate(){
return new date() + 6;
}
thanks.


#2

Are you referring to the ion datetime object, or are you referring to the datepicker in ionic native?


#3

Im referring to ionic datepicker.
this is my html code

 <ion-item>
      <ion-label floating>Date</ion-label>
      <ion-datetime displayFormat="DD-MM-YYYY" 
[(ngModel)]="userData.date" [min]="today()"></ion-datetime>
</ion-item>

#4

Here’s a working example with +2 years, I think, to remake for days you will not be difficult:

maxDate: any = new Date(new Date().setFullYear(new Date().getFullYear() + 2)).toISOString();


#5

Thanks brother, it’s work.