angular-material-components
angular-material-components copied to clipboard
Angular Material 14 / TypeScript 4.8.4 : date.getHours is not a function
Hello,
I have defined this component:
<ngx-mat-timepicker [(ngModel)]="myDatetime"></ngx-mat-timepicker>
and I have this error:
ERROR Error: Uncaught (in promise): TypeError: date.getHours is not a function
TypeError: date.getHours is not a function
at NgxMatNativeDateAdapter.getHour (angular-material-components-datetime-picker.mjs:3044:21)
at NgxMatTimepickerComponent._updateHourMinuteSecond (angular-material-components-datetime-picker.mjs:1731:39)
at NgxMatTimepickerComponent.writeValue (angular-material-components-datetime-picker.mjs:1694:14)
In your code:
invalid() {
return new Date(NaN);
}
getHour(date) {
return date.getHours();
}
getMinute(date) {
return date.getMinutes();
}