Dates
formatDuration
Make elapsed time readable.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { FormatDurationPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [FormatDurationPipe],
template: `{{ 90 | formatDuration: 'seconds': 'short': 'en' }}`,
})
export class ExampleComponent {
}
Template
{{ 90 | formatDuration: 'seconds': 'short': 'en' }}
Try it live.
The output below runs the packed library. Edit data, not code.
Use double quotes for text, or a number, array, object or null.
Ordered parameters: unit, style. Locale is controlled separately.
Applied to the live output.
Live template data
readonly value = 90;
readonly parameter0 = "seconds";
readonly parameter1 = "short";
{{ value | formatDuration: parameter0: parameter1: "en-US" }}
Rendered output
1 min 30 sec