I am dealing with an interface that includes a property dueOn
defined as type Date
:
export interface ListItem {
id: number;
description: string;
done: boolean;
steps: Step[];
dueOn: Date;
}
Instances of this interface have values like
dueOn: new Date("2020-08-01")
or dueOn: new Date()
.
When trying to display these dates in my HTML using the datepipe for formatting, I encountered the following issue:
<input type="datetime-local" [(ngModel)]="listItem.dueOn" value="{{listItem.dueOn | date:'yyyy-MM-dd'}}">
Although I expected the output to be formatted as 2020-08-01
or 2020-07-06
, it actually appears as:
Sat Aug 01 2020 02:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
Mon Jul 06 2020 15:38:45 GMT+0200 (Mitteleuropäische Sommerzeit)
Is there something I missed or why is the formatting not applied correctly?
Your assistance is greatly appreciated.