Reputation: 3268
I am using Angular 2, trying to convert a date object to HH:mm date format, with minutes to two decimal places, but when I use this:
{{date | date:"HH:mm"}}
I get 15:0 instead of 15:00.
I tried look at Angular 2 documentation but it's relatively limit so far, would appreciate any guidance about this and whether it is how Angular 2 formats time by default.
Upvotes: 12
Views: 67341
Reputation: 4736
You could use
date : 'shortTime'
or date :'h:mm a'
to get a result of this format 9:03 AM
Upvotes: 0
Reputation: 1975
According to the documentation your usage is correct: https://angular.io/docs/ts/latest/api/common/index/DatePipe-class.html
mm
should result in a 2-digit format.Are you using the most recent version?
The documentation also says Stability: Experimental
. This might still be a bug.
Upvotes: 10