【问题标题】:Timezone for date not working in Date pipe - angular 5日期的时区在日期管道中不起作用 - 角度 5
【发布时间】:2018-10-02 23:45:08
【问题描述】:

我正在从我的数据库中的日期列中获取数据。我尝试使用日期管道将其格式化为时区。下面是代码

<ng-container matColumnDef="invoiceDate">
          <mat-header-cell *matHeaderCellDef  mat-sort-header> Date </mat-header-cell>
          <mat-cell *matCellDef="let invoice"> {{invoice.invoiceDate | date: 'mediumDate' : 'EDT'}} </mat-cell>
        </ng-container>

它在我的本地环境中运行良好,而应用程序部署在 AWS 中,数据库是 AWS RDS (postgres),在这个环境中时区不起作用。 AWS 机器中的默认时区是 GMT。任何建议都会有很大帮助。例如数据库中的数据是 2018-08-18 12:00:00 但在前端它显示 2018-08-17 21:00:00

【问题讨论】:

    标签: typescript angular5 amazon-rds date-pipe


    【解决方案1】:

    为了解决这个问题,我编辑了具有确切时间增量的时区。

    <ng-container matColumnDef="invoiceDate">
                  <mat-header-cell *matHeaderCellDef  mat-sort-header> Date </mat-header-cell>
                  <mat-cell *matCellDef="let invoice"> {{invoice.invoiceDate | date: 'mediumDate' : '+0100'}} </mat-cell>
                </ng-container>
    

    【讨论】:

      猜你喜欢
      • 2019-01-18
      • 1970-01-01
      • 1970-01-01
      • 2021-12-05
      • 1970-01-01
      • 1970-01-01
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多