My goal is to display just the hours and minutes of a Date object retrieved from an API on the frontend as 'shortTime' format.
However, when I attempt to do so with the following code:
<h2>{{data.scheduleTime | date:'shortTime'}} - {{data.actualLandingTime | date:'shortTime'}}</h2><br>
I encounter the following error: InvalidPipeArgument: 'Unable to convert "03:45:00" into a date' for pipe 'DatePipe'
I suspect that Angular is having trouble identifying the object as a Date type...
The JSON objects are received through an API call. I have defined a model to specify the types of the objects. Both "scheduleTime" and "actualLandingTime" are dates in the model:
The FlightInfoModel looks like this:
actualLandingTime: Date;
scheduleTime: Date;
The data is received in the following format:
actualLandingTime: "2020-04-29T03:17:33.000+02:00"
scheduleTime: "03:45:00"
I only want to display the hours and minutes for both fields..
To take a closer look at the issue, here is how I fetch the API for that page:
data: FlightInfoModel;
ngOnInit(): void {
this.flightService.getFligthInfo<any>('129392719696922308').subscribe(response => {this.data = response, console.log(response)},
error => console.log(error));
}