Calculating between two times to get total hours
I'm trying to calculate two time to the get total of hour worked, For example:
2:00 - 14:00 = 12 hrs
0:00 - 0:00 = 24 hrs
13:50 - 14:00 = .50 hrs
I am a complete, never used Java before, novice. Here is what I put together.
if ((this.getField("End time").value.length == 0) || (this.getField("Start time").value.length == 0)) {
event.value = " 24.0";
}
else{
var timefinished = this.getField("End Time").value;
var timestarted = this.getField("Start Time").value;
var difflnMilliSeconds = Math.abs(timfinshed - timestarted)/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;
}
