4

In AngularJS, setting this line {{movie.duration | secondsToHHMM | date:'HH:mm'}} gives => 02:34 (2 hours and 34 minutes). I would like to have the output to be '2H 34M' instead of 02:34 format. How can I customize the time format in the placeholder?

'movie.duration', course comes from an ng-repeat, ng-repeat="movie in movies", btw

I'm brand new to AngularJS, your help will be much appreciated!

Thanks in advance!

1
  • If there isn't a filter option that gives you the desired output, I believe you can create a custom filter. I've never written myself, so I can't help further, but I think this is the direction you'll be heading. Commented Apr 28, 2016 at 18:01

1 Answer 1

1

You can add additional chars or strings in date formatting rules:

{{ movie.duration | secondsToHHMM | date: "HH'H' mm'M'" }}

https://docs.angularjs.org/api/ng/filter/date

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.