Develop a custom pipe named FormatTime
format-time.pipes.ts
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'formatTime'})
export class FormatTime implements PipeTransform {
transform(value: number): string {
return new Date(value * 1000).toISOString().substr(11, 8)
}
}
Import and include it in your module declarations
...
import { FormatTime } from './format-time.pipes';
@NgModule({
imports: [ BrowserModule, FormsModule ],
declarations: [ AppComponent, HelloComponent, FormatTime ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Usage in Template
<div class="col-2" *ngFor="let movie of moviesList">
<div class="movie">
{{ movie.attributes.title }}
<img [src]="movie.thumbnails.small">
{{ movie.attributes.duration | formatTime }}
</div>
</div>