I encountered an issue while trying to extract the hours and minutes from a date in Ionic.
Below is the code snippet from my .html file :
<ion-datetime displayFormat="HH:mm" [(ngModel)]='timeEntered1' picker-format="h:mm"></ion-datetime>
<ion-button (click)="getTime()"></ion-button>
Next, in my .ts file, I implemented the following logic:
timeEntered1 = new Date();
constructor() {}
getTime() {
console.log(this.timeEntered1.getHours());
}
The error message displayed is as follows:
this.timeEntered1.getHours is not a function