我无法在angular8材质表中显示时间戳记值。我在下面提供我的代码:
<ng-container matColumnDef="created_at">
<th mat-header-cell *matHeaderCellDef> Created At </th>
<td mat-cell *matCellDef="let element"> {{element.createdAt*1000 | date: 'MM/dd/yyyy'}} </td>
</ng-container>
<ng-container matColumnDef="updated_at">
<th mat-header-cell *matHeaderCellDef> Updated At </th>
<td mat-cell *matCellDef="let element"> {{element.updatedAt*1000 | date: 'MM/dd/yyyy'}} </td>
</ng-container>
输入值类似于createdAt: "2019-11-26T10:09:30.477Z" updatedAt: "2019-11-26T10:09:30.477Z"
,但根据我的代码,那里什么都没有显示。我需要在表格中显示实际的日期和时间。
答案 0 :(得分:0)
<ng-container matColumnDef="created_at">
<th mat-header-cell *matHeaderCellDef> Created At </th>
<td mat-cell *matCellDef="let element"> {{element.createdAt | date: 'MM/dd/yyyy'}} </td>
</ng-container>
<ng-container matColumnDef="updated_at">
<th mat-header-cell *matHeaderCellDef> Updated At </th>
<td mat-cell *matCellDef="let element"> {{element.updatedAt | date: 'MM/dd/yyyy'}} </td>
</ng-container>
您不需要将* 1000
添加到element.updateAt
,因为它不是时间戳,而是isoString