ancy
ancy

Reputation: 103

How to get HH:MM using pipe in angular 4

I am using angular 4 for the web application .Here I am passing HOURS to display in the Table list(HH:MM:SS).I want to show only HH:MM in the list.I am passing HH:MM:SS from the database.I used date pipe to show the HH:MM .But it displayed "InvalidPipeArgument: 'Invalid Date' for pipe 'DatePipe'" error. I am fetching both the format string data from db for eg: 543:43:09(HH:MM:SS) and 76:33(HH:MM) How can i achieve this?

The sample data's maybe

300:56:05

300:56

I want to tranform the data format in to 300:56(HH:MM) format

 <span>{{time | date:"hh:mm"}}</span>

Upvotes: 1

Views: 3820

Answers (1)

Mehdi Benmoha
Mehdi Benmoha

Reputation: 3935

A simple way could be using the SlicePipe:

Time: <span>{{time | slice:-3}}</span>

Doc: https://angular.io/api/common/SlicePipe

Enjoy !

Upvotes: 3

Related Questions