Calculating Total Time
I have the below javascript to calculate total time in a PDF form. The start time and finished time are two separate text boxes that are filled when the user pushes the approriate button for the start time or finished time or the use can manually enter the time. When the text boxes are empty, the TIME.TOTAL text box returns 0:0. If I press the start time and/or the finished time buttons, then the TIME.TOTAL text box returns NaN:NaN. I am relatively new to javascript.
var timefinished = this.getField("TIME.FINISHED").value;
var timestarted = this.getField("TIME.STARTED").value;
var datetimefinished = new Date('1970/01/01' + timefinished);
var datetimestarted = new Date('1970/01/01' + timestarted);
var difflnMilliSeconds = Math.abs(datetimefinished - datetimestarted)/1000;
// calculate hours
var hours = Math.floor(difflnMilliSeconds / 3600) % 24;
difflnMilliSeconds -= hours *3600;
// calculate minutes
var minutes = Math.floor(difflnMilliSeconds / 60) % 60;
difflnMilliSeconds -= minutes * 60;
// set field value to the difference
event.value = hours + ":" + minutes;
