How to disable dates before today and set default date as today ???
For default date u can bind value in .ts to datetime ngModel.
Remember ionic ISO 8601 datetime format for its value
.html
<ion-item>
<ion-label>Start Time</ion-label>
<ion-datetime displayFormat="YYYY-MMM-DD" [(ngModel)]="today"></ion-datetime>
</ion-item>
.ts
today = new Date().toISOString();
In addition to what @mobgg has explained, you can do the following:
In your component:
minDate: string = new Date().toISOString();
selectedDate: string = new Date().toISOString();
… and in the template:
<ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="selectedDate" [min]="minDate"</ion-datetime>
Check out the Min and Max in the API docs:
4 Likes
in this method i am unable to get past month full dates.