Format number of seconds as mm:ss in Angular 2

Discussão em 'Angular' iniciado por Chris, Janeiro 8, 2025.

  1. Chris

    Chris Guest

    I am displaying a number of seconds that counts down from 3600 to 0.

    <div class="time-box" *ngIf="p.value.playerTimer > 0">{{ p.value.playerTimer }}</div>


    I would like to format the number of seconds as minutes:seconds

    I hoped to be able to use DatePipe - https://angular.io/api/common/DatePipe

    <div class="time-box" *ngIf="p.value.playerTimer > 0">{{ p.value.playerTimer | date:'mmss' }}</div>


    But this doesn't work as it expects p.value.playerTimer to be a date object or number of seconds since the epoch.

    Is there another way to achieve this?

    Continue reading...

Compartilhe esta Página