Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Difference Between Two Times

Avatar

Level 1

I am building a work procedure in LiveCycle, and I want to track how long the procedure takes. To do this I have two time fields and then a third time field to find the difference between the two time fields. From looking at other discussion posts, I was able to find some Javascript code that did partially what I wanted, but I can't get the third time field to display in the format that I want. I have tried editing the Patterns of the fields and that didn't work. Could someone offer some advice on how to edit the format or help me with the code?  I couldn't figure out to attach the actual file, but I attached a picture of the PDF file and of the Javascript code that I used.  If you look at the TimeIn (HH:MM)  and TimeOut (HH:MM) fields (in the picture I attached), you'll notice that the TotalTime comes out as HMM, and I want it to come out as HH:MM.

Adobe Time Difference Example.jpg

Javascript Time Difference Code.jpg

Any help would be greatly appreciated!

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 6

 

this.rawValue = (totalHrs > 9 ? String(totalHrs) : '0' + String(totalHrs)) + ':' + (totalMins > 9 ? String(totalMins) : '0' + String(totalMins));

View solution in original post

2 Replies

Avatar

Correct answer by
Level 6

 

this.rawValue = (totalHrs > 9 ? String(totalHrs) : '0' + String(totalHrs)) + ':' + (totalMins > 9 ? String(totalMins) : '0' + String(totalMins));

Avatar

Level 1

That did the trick! Thankyou so much!!