1

I am not sure If I need to add anything here. I have a table with a date column. When the date column gets processed through the Angular date pipe, just to change the format to display, it subtracts a day from the actual date. I checked it without adding the date pipe, I get the actual date. What could be wrong?

<div *ngSwitchCase="'pending'" style="color:#367db9">
   {{ workOrder.postDate | date: 'MMM d, y'}}
</div>
Sumchans
  • 3,088
  • 6
  • 32
  • 59

1 Answers1

0

Have you tried it without the custom format?

{{ workOrder.postDate | date: 'MMM d, y'}} 

should be the same result as

{{ workOrder.postDate | date }} 

and the same as

{{workOrder.postDate | date:'mediumDate'}}

example: https://jsfiddle.net/Scotty3/bdmqxr5y/4757/

and https://next.angular.io/api/common/DatePipe

If not you'll need to check your source date variable.

scotty3
  • 153
  • 8
  • Hello @scotty3, I tried your code, it is still the same way. – Sumchans Jun 07 '18 at 04:05
  • @Sumchans what is the raw value of workOrder.postDate? try putting it into the jsfiddle I linked and see what you get. – scotty3 Jun 07 '18 at 04:18
  • Wow that looks strange, I tried the raw value which I get from the server, it works perfectly on the jsFiddle, then what would be wrong with my code then. Here is the raw value : 2018-06-11 00:00:00 – Sumchans Jun 07 '18 at 04:21
  • Found a fix for now from another post {{ workOrder.postDate.split("T")[0] | momentDatePipe}} https://stackoverflow.com/a/45582738/3826733 – Sumchans Jun 08 '18 at 03:00