0

Angular Date pipe not showing Date properly

I am using an angular date pipe on my page list.

{{ row.createdDate }} // 2019-11-04T06:32:24.352856
{{ row.createdDate | date: 'mm-dd-yyyy' }} // 32-04-2019
Mohammad Fareed
  • 1,927
  • 6
  • 26
  • 59

7 Answers7

7

mm is minute, you should use MM

Liam
  • 27,717
  • 28
  • 128
  • 190
Michał Tkaczyk
  • 732
  • 5
  • 18
3

correct way is like this

{{ row.createdDate | date: 'MM-dd-yyyy' }} // 11-04-2019
Ankur Patel
  • 478
  • 3
  • 6
3

Use

{{ row.createdDate | date: 'shortDate' }}
AyushKatiyar
  • 1,000
  • 8
  • 15
2

Please use like this.

{{ row.createdDate | date: 'MM-dd-yyyy' }} // This will give you correct date.

You can visit here to check the valid format option available for Date Pipe.

akpgp
  • 761
  • 6
  • 10
1

For month use MM... https://angular.io/api/common/DatePipe

{{ date | date: 'MM-dd-yyyy' }} 
1

Here you go for an exact result.

"mm" is minute format, u should capture it as "MM" for month.

{{ row.createdDate }} // 2019-11-04T06:32:24.352856
{{ row.createdDate | date: 'MM-dd-yyyy' }} // 31-04-2019

and the date you captured is 32 is there any reason in that ?

Regiz
  • 459
  • 4
  • 18
0
 https://angular.io/api/common/DatePipe
 'mm' for minute
 'MM' for months
 {{ date | date: 'MM-dd-yyyy' }} 

 Examples are given in en-US locale.
 'short': equivalent to 'M/d/yy, h:mm a' (6/15/15, 9:03 AM).
 'medium': equivalent to 'MMM d, y, h:mm:ss a' (Jun 15, 2015, 9:03:01 AM).
 'long': equivalent to 'MMMM d, y, h:mm:ss a z' (June 15, 2015 at 9:03:01 AM 
 GMT+1).
 'full': equivalent to 'EEEE, MMMM d, y, h:mm:ss a zzzz' (Monday, June 15, 
 2015 at 9:03:01 AM GMT+01:00).
 'shortDate': equivalent to 'M/d/yy' (6/15/15).
 'mediumDate': equivalent to 'MMM d, y' (Jun 15, 2015).
 'longDate': equivalent to 'MMMM d, y' (June 15, 2015).
 'fullDate': equivalent to 'EEEE, MMMM d, y' (Monday, June 15, 2015).
 'shortTime': equivalent to 'h:mm a' (9:03 AM).
 'mediumTime': equivalent to 'h:mm:ss a' (9:03:01 AM).
 'longTime': equivalent to 'h:mm:ss a z' (9:03:01 AM GMT+1).
 'fullTime': equivalent to 'h:mm:ss a zzzz' (9:03:01 AM GMT+01:00).