Search code examples
htmlangulartypescriptdate-pipe

Angular datepipe showing incorrect date/year in HTML table


I am very new in angular (I have two weeks expirience). I am using angular 8. I'm trying to format my date value to dd-MMM-yyyy using angular datepipe. The problem I have is that the datepipe is adding ONE year to the actual date value which makes it incorrect.

I have tried to even specify the datepipe timezone and locale but I still get the wrong date. I have tried this {{member.expiryDate | date: 'dd-MMM-yyyy': '+0200' : 'en-ZA'}}.

If I try to display the date without formatting, I get the correct value which also includes the time that I don't want.

I have attached the displayed date and the actual date. I just need the output to be like 05-Aug-2019 (example). enter image description here


Solution

  • Looks like browser based issue Stackblitz link

    today='15-Aug-2019 12:00:00 AM' 
    today | date: 'dd-MMM-yyyy a': '+0200' : 'en-ZA' }} 
    

    For me chrome shows

    enter image description here

    I would suggest you to look for alternative solution in this case.

    And Firefox shows (developer edition 68.0b12 (64-bit))

    enter image description here