I need help calculating hours when going between day like 5 am to 3 am the next day...
Here is my syntax that works within 12 hours but when I cross over to the next day... It won't work. Help please!!! Thanks in advance...
if ((this.getField("ShiftEND1").value.length == 0) || (this.getField("ShiftSTART1").value.length == 0)) {
event.value = " 0 ";
}
else{
var timefinished = this.getField("ShiftEND1").value;
var timestarted = this.getField("ShiftSTART1").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/.6 + " ";
}
