1

How to convert seconds to 10h 20m in moment.js, I did not find such a solution, who show 0h 01m(example)

result : 0h 01m
Uwis
  • 72
  • 7
  • You don't need moment js. Hint, hours = seconds / 3600, minutes = the remaining seconds / 60 and seconds = the remaining seconds – Cid May 12 '20 at 18:03
  • Does this answer your question? [How to convert seconds to HH:mm:ss in moment.js](https://stackoverflow.com/questions/31337370/how-to-convert-seconds-to-hhmmss-in-moment-js) – Cid May 12 '20 at 18:03
  • moment.js can't do it? – Uwis May 12 '20 at 18:04
  • You should know the answer already, you're supposed to have done some researches before posting a question – Cid May 12 '20 at 18:06
  • not, because this format has no text, I want a result with string : 02h : 20m – Uwis May 12 '20 at 18:06

1 Answers1

3

you can use smth like this

seconds = 18100;
moment.utc(1000 * seconds).format('H[h] mm[m]'); // "5h 01m"

UPD: so if you need zeros then format could be

seconds = 3700;
moment.utc(1000 * seconds).format('HH[h] mm[m]'); // "01h 01m"