Need to show time in "hh:mm:ss" format in angular 6

1k Views Asked by At

We have a response of time in below format like,

"time": "05:36:38.088"

or

"time": "05:36:38+088"

We need to show it in "hh:mm:ss" or "hh:mm".

I tried to convert it by using split and if - else conditions, But as both format will need diff splits, so searching for custom pipe to handle both conditions.

1

There are 1 best solutions below

0
On

You can use the date pipe for display time or date in specific format. For more documentation please refer this link.

In your case, you can bind the time in html like

{{time | date: 'shortTime'}}

or

{{time | date: 'mediumTime'}}