日期的时区在日期管道中不起作用 - 角度5

问题描述 投票:0回答: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' : 'EDT'}} </mat-cell>
        </ng-container>

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

typescript angular5 amazon-rds date-pipe
1个回答
0
投票

我编辑了时区,确定了解决此问题的时间增量。

<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>
© www.soinside.com 2019 - 2024. All rights reserved.