angular - Angular 6 如何编辑日期格式?

CDC
        <ng-container *ngFor="let column of columns">
      <ng-container *ngIf="column.isModelProperty" [matColumnDef]="column.property">
        <mat-header-cell *matHeaderCellDef mat-sort-header> {{ column.name }}</mat-header-cell>
        <mat-cell *matCellDef="let row">
          <span class="fury-mobile-label">{{ column.name }}</span>
          {{ row[column.property] }}
        </mat-cell>
      </ng-container>
    </ng-container>

export class Senderv2 {
    serviceCode: string;
    insertDate : DatePipe;

    constructor(senderv2) {
        this.serviceCode = senderv2.serviceCode;
        this.insertDate = senderv2.insertDate;
    }
}

export class ListColumn {
  name?: string;
  property?: string;
  visible?: boolean;
  isModelProperty?: boolean;
  displayFn: any;
}

数据从数据库到表。数据库中的数据类型datetime Column 属性insertDate 如何编辑日期格式?

舍温格

您可以使用 Angular 的DatePipe以自定义格式编辑日期

附上Stackblitz Demo供您参考

示例图:

import { DatePipe } from '@angular/common';


class Sender {

     currentDate: any = new Date();    

     constructor(private datePipe: DatePipe) {}   // Be sure to import this as a provider either inside Component or on your Module

     transformDate() {
         this.currentDate = this.datePipe.transform(this.currentDate, 'yyyy-MM-dd');  // 2018-11-23
     }

}

您还可以参考此答案以获取有关实施DatePipe 的更多信息

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章