Skip to content

Angular pipe to format given milliseconds or seconds to HH:mm:ss or DD:HH:mm:ss format.

License

Notifications You must be signed in to change notification settings

wie-niet/ng-duration-format-pipe

 
 

Repository files navigation

DurationFormat Angular Pipe

Angular 2 and 4 pipe to convert milliseconds or seconds to 'HH:mm:ss' format.

New: Also possible to convert milliseconds or seconds to

00d, 00h, 00m, 00s

or

00 days, 00 hours, 00 minutes, 00 seconds.

Options and use

{{value_given_milliseconds | durationFormat: 'ms':'hhmmss'}}
{{value_given_seconds | durationFormat: 's':'hhmmss'}}

Output: '00:00:00'
{{value_given_milliseconds | durationFormat: 'ms':'ddhhmmss'}}
{{value_given_seconds | durationFormat: 's':'ddhhmms'}}

Output: '00d, 00h, 00m, 00s'
{{value_given_milliseconds | durationFormat: 'ms':'ddhhmmssLong'}}
{{value_given_seconds | durationFormat: 's':'ddhhmmssLong'}}

Output: '00 days, 00 hours, 00 minutes, 00 seconds'

You can use arguments 'ms' or 's' to specify type of a input value. You can use second argument 'hhmmss', 'ddhhmmss' or 'ddhhmmssLong' to specify output format.

Both arguments are REQUIRED

There is no week/month/year options. Hours will go past 24 hours when format is set to 'hhmmss' and days go past 7 days.

Compatibility

This pipe does work with a IE11 / Edge browsers. These browser has a open bug that prevents use of a Angular 2 Date pipe.

chakra-core/ChakraCore#1223

About

Angular pipe to format given milliseconds or seconds to HH:mm:ss or DD:HH:mm:ss format.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 75.1%
  • JavaScript 17.2%
  • HTML 7.0%
  • CSS 0.7%