Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 - Date Pipe, Time Conversion HH:mm to 2 Decimal Places

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.

like image 719
Ryan S Avatar asked Jun 24 '16 14:06

Ryan S


1 Answers

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.

like image 96
Stefan Pries Avatar answered Oct 16 '22 17:10

Stefan Pries