Ionic V4 - ion-datetime model format problem

Hi!
How could I get the value of the model in normal date format? At this point I’m getting the object what you see below. I don’t want to link them one by one if not neccesary.

My code:

<ion-datetime name="delivery_date" [(ngModel)]="deliveryNoteFormData.delivery_date" required display-format="YYYY-MM-DD" picker-format="YYYY-MM-DD"></ion-datetime>

Model value:

 {
  "year": {
    "text": "2018",
    "value": 2018,
    "columnIndex": 0
  },
  "month": {
    "text": "01",
    "value": 1,
    "columnIndex": 1
  },
  "day": {
    "text": "01",
    "value": 1,
    "columnIndex": 2
  }
} 

Thanks

if you use momentjs

const day: number = $event.detail.value.day.value;
const month: number = $event.detail.value.month.value;
const year: number = $event.detail.value.year.value;

const theDate: Date = moment().year(year).month(month - 1).date(day).toDate();
1 Like

I wanted to avoid this, but if there is no other solution, thank you for help :slight_smile:

they might be, I just went straight forward you know :wink: