I am trying to get the date from the datepicker and save it in sql server but the output is coming like '1538107200000'. What format is it and how to convert it to a date format which is compatible with sql server date format.
in component.html
<input matInput [matDatepicker]="picker" placeholder="enter date"
(dateInput)="addEvent('input', $event)">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
in component.ts
addEvent(type: string, dinput: MatDatepickerInputEvent<Date>) {
this.dinput.push(`${dinput.value}`);
this.date = new Date(this.dinput[0].toString());
this.dates = moment(this.date, 'YYYY-MM-DD').toString();
console.log(this.dates);
}
this is giving error of invalid date. How to fix it? Please help.