# Milliseconds to Hour:Minutes:Seconds format (double digits)

**URL:** <https://forum.inductiveautomation.com/t/milliseconds-to-hour-minutes-seconds-format-double-digits/9512>\
**Category:** Ignition\
**Created:** [January 6, 2015, 5:42pm UTC](https://forum.inductiveautomation.com/t/milliseconds-to-hour-minutes-seconds-format-double-digits/9512 "2015-01-06T17:42:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gratliff](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gratliff](https://forum.inductiveautomation.com/u/Gratliff)\
**Post date:** [January 6, 2015, 5:42pm UTC](https://forum.inductiveautomation.com/t/milliseconds-to-hour-minutes-seconds-format-double-digits/9512/1 "2015-01-06T17:42:29Z")

</div>

Thanks to njsd on a post in another topic, I found this solution to converting milliseconds to Hours:Minutes:Seconds via an expression. It works very well (Thanks njsd) ![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:") .

Make a label, and then tie the value to the following expression

[color=#0000FF]  
Code:  
stringFormat("%s:%s:%s",  
toInt(floor({TagPath/Timer Tag}/3600000)),  
toInt(floor(({TagPath/Timer Tag}%3600000)/60000)),  
toInt(floor(({TagPath/Timer Tag}%60000)/1000))  
)  
[/color]

Is there a way to force the string format to always show two digits per segment? For example, when either the hours, minutes or seconds values are single digit values you get something like this: 12:1:0.

I would prefer 12:01:00.

Any assistance would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [January 6, 2015, 6:21pm UTC](https://forum.inductiveautomation.com/t/milliseconds-to-hour-minutes-seconds-format-double-digits/9512/2 "2015-01-06T18:21:49Z")

</div>

Use this:

`
stringFormat("%d:%02d:%02d",
toInt(floor({TagPath/Timer Tag}/3600000)),
toInt(floor(({TagPath/Timer Tag}%3600000)/60000)),
toInt(floor(({TagPath/Timer Tag}%60000)/1000))
)`  
Cheers,

---

<div class="post-metadata">

**Author:** ![k.jain](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@k.jain](https://forum.inductiveautomation.com/u/k.jain)\
**Post date:** [January 4, 2018, 8:21pm UTC](https://forum.inductiveautomation.com/t/milliseconds-to-hour-minutes-seconds-format-double-digits/9512/3 "2018-01-04T20:21:52Z")

</div>

Didn;'t work for me. I am trying to use a numeric label and bind the expression to the one that you mentioned!

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [January 4, 2018, 9:44pm UTC](https://forum.inductiveautomation.com/t/milliseconds-to-hour-minutes-seconds-format-double-digits/9512/4 "2018-01-04T21:44:24Z")

</div>

You can’t use a numeric label because the expression gives you a string, not a number. Try a regular label instead.
