JoSeBu
JoSeBu

Reputation: 305

Set a default value in an ion-datetime Ionic 4

I want to make an edit form and I need to set a default date in the ion-datetime.

The .html

<ion-datetime #fecha displayFormat="DD/MM/YYYY" [(ngModel)]="myVar" pickerFormat="DD MM YYYY" doneText="Ok" cancelText="Cancelar"></ion-datetime>

The .ts

public myVar = "15-06-1999";

Upvotes: 5

Views: 10971

Answers (1)

Ajith
Ajith

Reputation: 845

myDate: String = new Date(yourdate).toISOString();
<ion-datetime displayFormat="MMM DD, h:mm A" [(ngModel)]="myDate"></ion-datetime>

Upvotes: 16

Related Questions