# Convert seconds to HH MM SS

**URL:** <https://forum.inductiveautomation.com/t/convert-seconds-to-hh-mm-ss/8739>\
**Category:** Ignition\
**Created:** [July 16, 2014, 11:40pm UTC](https://forum.inductiveautomation.com/t/convert-seconds-to-hh-mm-ss/8739 "2014-07-16T23:40:28Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 15, 2019, 4:27pm UTC](https://forum.inductiveautomation.com/t/convert-seconds-to-hh-mm-ss/8739/9 "2019-01-15T16:27:27Z")

</div>

> [@nick.schuetz](#):
>
> `numberFormat(hoursBetween({Root Container.Popup Calendar.date}, now()), '00') + ':' + numberFormat(minutesBetween({Root Container.Popup Calendar.date}, now()) % 60, '00') + ':' + numberFormat(secondsBetween({Root Container.Popup Calendar.date}, now()) % 60, '00')`

This is _almost_ the "right" answer - slightly cleaner/better is to just use [`stringFormat`](https://docs.inductiveautomation.com/display/DOC79/stringFormat):

```auto
stringFormat("%02d:%02d:%02d", 
	hoursBetween({Root Container.Popup Calendar.date}, now()),
	minutesBetween({Root Container.Popup Calendar.date}, now()) % 60,
	secondsBetween({Root Container.Popup Calendar.date}, now()) % 60
)

```

Note that it's worth a disclaimer that this will "break" if you overflow 24 hours. You can solve that with an additional if statement and more complex logic, but I'll leave that for the reader.

---

_[View the full topic](https://forum.inductiveautomation.com/t/convert-seconds-to-hh-mm-ss/8739)._
