Time Hours Calculation in Acrobat Pro X

New Here ,
May 24, 2018 May 24, 2018

Copy link to clipboard

Copied

Customer asked how to make it calculate. It was summing the hours up, but not adding it as time. I don't know much about this, customer created this on her own. We don't have anybody at our company that does this. There is some JavaScript code in there to do the calculation, but I have no idea how I know if there is a problem with it and how to make it work and calculate properly. Any help much appreciated! Thank you!

Before I messed with it and added the last time to see if it was working and how, it has 6.9 in there to total up the top 3.

I noticed there is just no code for the total field. All the other Total hours Fields had a section of that JavaScript code below, but the bottom Total hours for day didn't have JavaScript math in it which is why it's not working. The customer did have Sum selected which is why it was adding them wrong. I took that off, but I have no idea how to put a calculation in that field. I mean what the JavaScript Calculation should be. Hoping somebody could be of help. Thanks!

This is the code in there for the Total Hours box:(Assuming I am doing this right, went to JavaScript and clicked Edit all JavaScripts.)

//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------

//<AcroForm>
//<ACRO_source>total hoursRow1:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow1:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow1");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow1");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow10:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow10:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow10");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow10");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow11:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow11:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow11");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow11");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow2:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow2:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow2");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow2");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow3:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow3:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow3");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow3");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow4:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow4:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow4");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow4");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow5:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow5:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow5");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow5");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow6:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow6:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow6");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow6");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow7:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow7:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow7");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow7");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow8:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow8:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow8");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow8");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>total hoursRow9:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:total hoursRow9:Calculate ***********/
   event.value = "";
   var inTimeField = this.getField("start timeRow9");
   var inTime = inTimeField.value;
   var outTimeField = this.getField("enD timeRow9");
   var outTime = outTimeField.value;
   if (inTime!="" && outTime!="") {
    var inTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + inTime);
    var outTimeDate = util.scand("mm-dd-yyyy HH:MM", "01-01-2012 " + outTime);
    if (inTimeDate!=null && outTimeDate!=null) {
     if (inTimeDate.getTime()>outTimeDate.getTime()) {
      //console.println("Error: " + inTimeField.name + " is before " + outTimeField.name);
      outTimeDate.setTime(outTimeDate.getTime()+86400000);
     }     var totalTimeInMins = (outTimeDate.getTime() - inTimeDate.getTime()) / 60000;
     var totalTime_hours = Math.floor(totalTimeInMins / 60);
     var totalTime_mins = Math.floor(totalTimeInMins % 60);
     var totalTime_minsString = totalTime_mins<10 ? "0"+totalTime_mins : ""+totalTime_mins;
     event.value = totalTime_hours + ":" + totalTime_minsString;
    }
   }
//</ACRO_script>
//</AcroForm>

TOPICS
Acrobat SDK and JavaScript, Windows

Views

661

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 24, 2018 May 24, 2018

Copy link to clipboard

Copied

There have been many examples posted to this forum, you can search to find them. There are easier ways to code the problem by using document level functions to perform the repeated tasks, like converting time string fields to date object values and then to a numeric value with a common base value. The task can also be made easier by using hierarchical field names.

A review of the calculations shows that all time differences are being calculated for January 1, 2012. This is a serious flaw if the date and time period covers the interval when there is a change in Day Light Savings time or BST, British Summer Time? I expect the calculation will be wrong by 1 hour.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

Thank you! I did try to search the forum and say many replies and stuff, but I didn't understand and was confused a lot since I am not experienced in this. I'll keep trying anyway.

And I didn't put that code in there or know where the customer got it from. Customer had created this document and couldn't get it to work right so then asked us if we knew how. Nobody in our office knows this stuff well enough though. Thank you for your time.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

Without a working form it is pretty hard to tell exactly what the problem is.

Are all the field names in the scripts spelled correctly?

Are the time values being converted properly?

Is the total hours worked field having a "format does not match" error?

Or something entirely different?

The first 2 issues can be caught and alerted in the script by checking result of the getField or util.scand returning a null value.

For the third issue, the time format only allows for the 24 hours in the day, i.e. 00:00 through 23:59, and any number 24:00 or larger will result in an error. The hours to be added needed to be added in minutes, so either the daily hours worked need to be converted from the format of HH:MM to minutes and summed for the grand total time worked. Or the daily total hours are set to the total minutes worked and a custom format scrip converts the minutes to display "HH:MM". This would allow one to just sum the total minutes worked and then format the grand total time worked.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

So the start time and end time to total hours calculate fine. It's just the total hours below that don't. Customer had chose sum to calculate that field which doesn't work of course.

Field Names: I looked through some of it, not all of it as it is hard to tell since I don't completely know what I am looking at, it seems like it though from what I could tell. I'm assuming if they weren't matching, it wouldn't be able to calculate hours. Like the start and end for the day. There is two totals one for like 1pm - 2pm and then a total at the bottom that totals up all of the hours for the day, which is the one that doesn't work because it doesn't have a formula. I mean it did, but customer had chose sum.

I don't know the answer to the time values being converted properly since this code is almost like gibberish to me. It's not my field of study. This is just something got tossed to me because we don't have anybody at our company that knows this and because I have Acrobat Pro. (Which apparently means I am a pro at Acrobat, but I am not.)

I don't have any errors. I think because there is nothing wrong. It's just that it can't total the hours for the day on the bottom because I don't know what to put in there to make it do that. Maybe I will have to let the customer know we can't resolve this since we don't have anybody knowledgeable enough. Thank you for trying to help me out! I wish I could understand this more so I could have better responses, I apologize.

Each total hours field has code for the math which that part is working, but I know that this code will determine the code needed for the total hours.

FieldCode.JPG

Total hours on bottom, what customer had, which I know won't work.

TimeCalculation.JPG

The circled is the only thing that does not work. No error, just not the proper calculation. The red circled area.

AdobeForm.JPG

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

I see the 2012 in the code though. I can just change that to 2018? I am assuming customer must have copied this code from somewhere.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

You can change it, but it won't make any difference.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

Okay. Starting to think I should have studied JavaScript more back in college. Ha!

So I know what I want it to do, but no idea how to write it out.

I wanted it to add total hoursRow1 + total hoursRow2 and so on to equal total hourstotal hours. (Don't know who named these fields!) And to add it in time/hours instead of decimals.

I know I want it to be like: total hoursRow1 + total hoursRow2 + total hoursRow3 = total hourstotal hours (But not to add as decimal points. Just don't know how to write the code for it.)

I'm assuming it's similar to how the other fields are adding the start and end time, but not sure how to even pick apart the code to make it do that.

Like var inTimeField = this.getField("total hoursRow1"); and keep doing that for all 11 fields? No that can't be right because then you take that field and do something with it or is it. Ahh, confusing. Never mind, that doesn't make sense. I guess I have no idea. I was trying to understand the current code, like in English.

So the var is just defining a field name, then it does one of those always have confused me for some reason if statements.

So if the inTimeField and outTime have values, take in time = then it has something about date and time + inTime. (not sure what is going on there)

Then something with the outTime with date and time. If the inTime and outTime are empty field is then empty I think if I am understanding.

Then this part I don't understand at all either, if inTimedate.getTime and outtime.getTime (don't know where getTime came from) then print an error?

Then another variable defined totalTimeInMins = (Out time.getTime (don't know what that is or means) - inTimeDate.getTime / 60000 (why dividing by 60000?)

Then totalTime_hours = math.floor (totalTimeInMins/60, so dividing the minutes by 60 to convert to hours.

I don't know what the totalTimeInMins % 60 does though.

(I just took this code from one of the fields, like how they are above in the original post.) I guess not really important. I was just trying to wrap my head around it.

So I can barely understand this code and then to write some for the total of the hours is like more then my brain can understand or handle! I took a beginners class many years ago on JavaScript and was never very good at it and always had to have help and was not planning on needed to ever use it again and here I am. Ha! Anyway, thank you for have been trying to help me.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

Actually, I think I wrote that code...

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 29, 2018 May 29, 2018

Copy link to clipboard

Copied

Crazy, I don't know where customer had got it from so probably!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

The customer entered the date string "01-01-2012" just to have a required date value for processing.

The choice of calculation for the total hours, uses some behind the scenes JavaScript to convert the "numeric" values, actually hours and minutes, and sums them like decimal values.

1.3 + 3.3 + 2.3 =  6.9 not the 7 hours 30 minutes that one would expect.

JavaScript's smallest unit of time measurement is the millisecond or 1/1000 of a second. And using the "new Date()" method or the "util.scand()" method will create a date object whose value is the number of 1/1000 seconds since January 1, 1970. This value can be converted to minutes by dividing the value by 1,000 to get the number of seconds and then by 60 seconds / minute. Taking difference of the end and start date time combinations will provide the difference between the 2 times in minutes.

If each of the fields for individual intervals is reported as the difference in minutes, then one only needs to sum the individual differences fields. A nice feature of Acrobat forms is that the formatting applied to a field only affects the displayed or seen value. So one can write a custom format script that converts any number of minutes into the format of Hours:Minutes.

With time calculations I have found that using a function or reusable block of code to convert date and time values into minutes and a function to convert minutes to Hours:Minutes makes the coding for individual forms appear less complex..

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines