# Converting an Integer to Time

**URL:** <https://forum.inductiveautomation.com/t/converting-an-integer-to-time/41432>\
**Category:** General Discussion\
**Tags:** ignition80\
**Created:** [December 11, 2020, 5:48pm UTC](https://forum.inductiveautomation.com/t/converting-an-integer-to-time/41432 "2020-12-11T17:48:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom.R](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@Tom.R](https://forum.inductiveautomation.com/u/Tom.R)\
**Post date:** [December 11, 2020, 5:48pm UTC](https://forum.inductiveautomation.com/t/converting-an-integer-to-time/41432/1 "2020-12-11T17:48:38Z")

</div>

Hello,  
Not sure how to go about this or if it is even possible. I have an integer tag that I am using from a 3rd party OPC Server (Kepware) that I am needing in Time Format. The value reads “124554” which is correct. I just need it to display 12:45:54. Can this be done. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 11, 2020, 6:07pm UTC](https://forum.inductiveautomation.com/t/converting-an-integer-to-time/41432/2 "2020-12-11T18:07:04Z")

</div>

Sure. Replace all instances of `valueSourceTag` with the path to your integer tag.

```java
if({valueSourceTag} >= 100000,
	// Use left two digits for hours for times 10:00:00 or greater.
	left({valueSourceTag}, 2) + ":" + substring({valueSourceTag}, 2, 4),
	// Use only 1 left digit for hours for times less than 10:00:00.
	left({valueSourceTag}, 1) + ":" + substring({valueSourceTag}, 1, 3)
)
+ ":" + right({valueSourceTag}, 2)

```

---

<div class="post-metadata">

**Author:** ![Tom.R](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@Tom.R](https://forum.inductiveautomation.com/u/Tom.R)\
**Post date:** [December 11, 2020, 6:11pm UTC](https://forum.inductiveautomation.com/t/converting-an-integer-to-time/41432/3 "2020-12-11T18:11:35Z")

</div>

> [@witman](#):
>
> if({valueSourceTag} \> 95959, left({valueSourceTag}, 2) + ":" + substring({valueSourceTag}, 2, 4), left({valueSourceTag}, 1) + ":" + substring({valueSourceTag}, 1, 3) ) + ":" + right({valueSourceTag}, 2)

Thank you. Thats just what I needed. Worked perfectly!

---

<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:** [December 11, 2020, 6:20pm UTC](https://forum.inductiveautomation.com/t/converting-an-integer-to-time/41432/4 "2020-12-11T18:20:26Z")

</div>

A couple other options:

```auto
groupConcat(split({Root Container.Numeric Text Field.intValue}, "(?<=\\G.{2})"), "parts", ":")`

```

```auto
concat(
	numberFormat(
		floor({Root Container.Numeric Text Field.intValue} / 10000), "00"
	),
	":",
	numberFormat(
		floor({Root Container.Numeric Text Field.intValue} % 10000 / 100), "00"
	),
	":",
	numberFormat(
		floor({Root Container.Numeric Text Field.intValue} % 100), "00"
	)
)	

```
