# Return Hour and mins between two millis values

**URL:** <https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543>\
**Category:** Ignition\
**Created:** [October 30, 2019, 10:23pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543 "2019-10-30T22:23:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [October 30, 2019, 10:23pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/1 "2019-10-30T22:23:49Z")

</div>

If a guy had the two following component props value how could he return the time between the two? As “hh:mm:ss” . Through scripting or expressions. All the functions and expressions return whole values. and when I end up trying to do math I get wrong hours.

```auto
timeE:1,572,425,661,000
timeS:1,572,420,540,000

```

timeE - timeS – should return : 01:25:07… I think or 1:25:21

```auto
dateFormat(({this.custom.newlot.timeE}-{this.custom.newlot.timeS}), "hh:mm:ss")

```

returns 07:25:21

How come?

I know almost nothing about **java.text.SimpleDateFormat**

timeS = 10/30/2019 02:47:54  
timeE = 10/30/2019 04:13:18

---

<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:** [October 30, 2019, 11:00pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/2 "2019-10-30T23:00:12Z")

</div>

```auto
dateFormat(
	fromMillis(
		{this.custom.newlot.timeE} - {this.custom.newlot.timeS}
	), "HH:mm:ss"
)

```

Something like this should work.

Reference:  
[https://docs.inductiveautomation.com/display/DOC80/dateDiff](https://docs.inductiveautomation.com/display/DOC80/dateDiff)  
[https://docs.inductiveautomation.com/display/DOC80/\*Between](https://docs.inductiveautomation.com/display/DOC80/*Between)  
[https://docs.inductiveautomation.com/display/DOC80/dateFormat](https://docs.inductiveautomation.com/display/DOC80/dateFormat)

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [October 31, 2019, 1:06pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/3 "2019-10-31T13:06:50Z")

</div>

```auto
dateFormat(fromMillis({this.custom.newlot.timeE} - {this.custom.newlot.timeS}), 
"hh:mm:ss")

```

returns 07:55:46

```auto
dateFormat(fromMillis({this.custom.newlot.timeE} - {this.custom.newlot.timeS}),
 "HH:mm:ss")

```

returns 19:55:46

with:

```auto
timeS:1,572,508,427,000 (10/31/2019 02:53:47)
timeE:1,572,515,373,000 (10/31/2019 04:49:33)
```

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [October 31, 2019, 1:14pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/4 "2019-10-31T13:14:22Z")

</div>

Could locale be causing an issue?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 31, 2019, 1:23pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/5 "2019-10-31T13:23:01Z")

</div>

Your formats don’t match. 😉

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 31, 2019, 1:23pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/6 "2019-10-31T13:23:05Z")

</div>

Any use of a delta between timestamps will have to be translated to hms in UTC, since deltas have no time zone. Consider just using modulus to pick off the components.

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [October 31, 2019, 1:32pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/7 "2019-10-31T13:32:58Z")

</div>

> [@pturmel](#):
>
> will have to be translated to hms in UTC

Ohhh that makes sense... And I am -6 hours different than utc..... That explains 07:55:46

> [@JordanCClark](#):
>
> Your formats don’t match. 😉

Where at?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 31, 2019, 1:34pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/8 "2019-10-31T13:34:35Z")

</div>

> [@wking](#):
>
> Where at?

Sorry, that was a misread on my part.

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [October 31, 2019, 4:11pm UTC](https://forum.inductiveautomation.com/t/return-hour-and-mins-between-two-millis-values/29543/9 "2019-10-31T16:11:34Z")

</div>

Lol

 ![raw%20time](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/97bbace4e7b3357a2764865fb487f40e374c9f8b.jpeg)
