Colin Wong
Colin Wong

Reputation: 131

How to set default date(today's date) of ion-datetime?

So this is my html code, i would like to set the default date of the datepicker to today's date. How should i go about doing this?

<ion-item>
      <ion-label floating>Date</ion-label>
      <ion-datetime displayFormat="DD MMMM YYYY" pickerFormat="DD MMMM YYYY" [(ngModel)]="request.date" (Value)="myDate" ></ion-datetime>
    </ion-item>

Upvotes: 2

Views: 1631

Answers (1)

Swapnil Patwa
Swapnil Patwa

Reputation: 4099

Assign today's date value like this -

this.request.date = new Date().toJSON().split('T')[0];

Upvotes: 2

Related Questions