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

50,306

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.

Share:
50,306
Ryan S
Author by

Ryan S

I'm a recent BSc Creative Computing graduate currently working as a Web Developer in Malta.

Updated on July 18, 2022

Comments

  • Ryan S
    Ryan S almost 2 years

    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.

  • Ryan S
    Ryan S almost 8 years
    I'm using ^2.0.0-rc.2, I can try rc3
  • Ryan S
    Ryan S almost 8 years
    As Stefan and Assylias have indicated, this was indeed a bug in Angular rc2, which was fixed last week. When upgrading to rc3, this worked like a charm.
  • Juan Cruz Méndez
    Juan Cruz Méndez over 4 years
    Also the date object should be standard: w3.org/TR/NOTE-datetime