Time Elapsed Calculation HH:MM:ss
Hello Experts,
I'm a bit of a java rookie but usually I can get a code to swing out the way I need it to do.
I have spent a week working through forums searching for a solution but as yet have not found a code that is effective.
I have a PDF which needs to calculate the time difference between two sets of time input.
Time1 = HH:MM:ss
and
Time3 = HH:MM:ss
OR (ideally)
Time1 = DD/MM/YYYY HH:MM:ssand
Time3 = DD/MM/YYYY HH:MM:ss
I have managed to make the date calculation work stand alone but ideally I would have it occur in the one calculation.
The code is reactive and only occurs with a specific drop down result.
Below is the only time calculation I have managed to get to work. It displays accurately in decimals, but does not calculate seconds yet, and try as I might when I modify the code to attempt the required format I can't get it to work.
I am using Adobe 2017
//get whatif value
var cDisplay = this.getField("Dropdown8").value
// compute number of days only if there are values for both dates and displays
if(cDisplay != "A" & cDisplay != "C" & cDisplay != "D" & cEnd != "" & cStart != '')
//
var cDisplay = this.getField("Dropdown8").value
var strStart = this.getField("Time1").value;
var strEnd = this.getField("Time3").value;
strStart = strStart + " 1/1/70";
strEnd = strEnd + " 1/1/70";
if(cDisplay != "A" & cDisplay != "C" & cDisplay != "D" & cEnd != "" & cStart != '')
{
var timeStart = util.scand("hh:MM ", strStart);
var timeEnd = util.scand("hh:MM ", strEnd);
if (timeEnd < timeStart) {
var strEnd = this.getField("Time3").value
var strEnd = strEnd + " 1/2/70";
var timeEnd = util.scand("hh:MM", strEnd);
var diff = timeEnd - timeStart;
var oneHour = 60 * 60 * 1000;
var timeleft = (diff/oneHour);
}
var diff = timeEnd - timeStart;
var oneHour = 60 * 60 * 1000;
var timeleft = (diff/oneHour);
//event displayed
event.value = timeleft.toFixed(2);
} else {
event.value = " ";
}
