1

I have the following code in my template:

<div>{{createdOn | date:'yyyy-mm-dd'}}</div>

The value of createdOn is 1565762489936 in milliseconds. In terms of date it is 'Wed 14 August 2019'.

Instead I get '2019-31-14'. The month value is wrong.

Whats the issue here?

insertusernamehere
  • 23,204
  • 9
  • 87
  • 126
Mandroid
  • 6,200
  • 12
  • 64
  • 134

2 Answers2

1

According to angular.io we can custom month as follows, enter image description here

So in your case simple mm should be capital

Community
  • 1
  • 1
INDRAJITH EKANAYAKE
  • 3,894
  • 11
  • 41
  • 63
0

When using Angular’s Date Pipe you need to keep its custom format options in mind:

Lowercase mm will print the minute with two digits.

What you should use instead is uppercase MM which represents the month:

<div>{{createdOn | date:'yyyy-MM-dd'}}</div>
insertusernamehere
  • 23,204
  • 9
  • 87
  • 126