我需要从 ion-datetime 中选择的值中获​​取特定参数(日期、月份、年份)

I need get especific parametres(date, month, year) from value selected in ion-datetime

当从 ion-date 时间获取值并在控制台打印它时,只会打印一个字符串。我如何从所选值中获取特定值(日期、月份、年份)?

这是我的代码:

fecha_nacimiento:Date;
public ageFromDOB($dateOfBirth) {
console.log($dateOfBirth);
}

HTML:

<ion-item>
      <ion-label position="floating">Fecha de nacimiento</ion-label>
      <ion-datetime type="date" displayFormat="MM/DD/YYYY" min="1920-03-14" max="2019-12-31"  
 [(ngModel)]="userre.fecha_nacimiento" (ionChange)="ageFromDOB($event)"></ion-datetime>
    </ion-item>

试试这个

public ageFromDOB($dateOfBirth) {
    console.log($dateOfBirth);
    console.log(new Date($dateOfBirth.detail.value).getFullYear());
    console.log(new Date($dateOfBirth.detail.value).getDate());
    console.log(new Date($dateOfBirth.detail.value).getMonth() + 1); // month value has index 0 so add 1 to it.

  }