Timezone for date not working in Date pipe - angular 5

3.1k Views Asked by At

I am fetching data from date column in my DB. I try to format it with the timezone using the date pipe. Below is the code

<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>

It works fine in my local environment, whereas the application is deployed in AWS and the DB is AWS RDS (postgres) and in this environment the timezone isn't working. The default timezone in AWS machine is GMT. Any suggestions will be of great help.For example the data in DB is 2018-08-18 12:00:00 but in the front end it shows 2018-08-17 21:00:00

1

There are 1 best solutions below

0
On BEST ANSWER

I edited the timezone with the exact time increment for this issue to get resolved.

<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>