【发布时间】:2020-10-26 15:46:08
【问题描述】:
我有一个带有dueOn 属性的接口,它是一个Date:
export interface ListItem {
id: number;
description: string;
done: boolean;
steps: Step[];
dueOn: Date;
}
它的值类似于dueOn: new Date("2020-08-01") 或dueOn: new Date()。
在我的 HTML 视图中,我尝试使用日期管道对其进行格式化:
<input type="datetime-local" [(ngModel)]="listItem.dueOn" value="{{listItem.dueOn | date:'yyyy-MM-dd'}}">
我希望这个输出是 2020-08-01 或 2020-07-06 但我得到:
2020 年 8 月 1 日星期六 02:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
2020 年 7 月 6 日星期一 15:38:45 GMT+0200 (Mitteleuropäische Sommerzeit)
我是不是忘记了什么或者为什么格式不正确?
提前致谢
【问题讨论】:
标签: angular typescript