Calculating Total of total overtime & calculating time after 12 midnight
- October 17, 2024
- 2 replies
- 4036 views
I used below code from other post to calculate total time (custom calculate script):
if ((this.getField("To1").value.length == 0) || (this.getField("From1").value.length == 0)) {
event.value = " 0 Hours 0 Minutes";
}
else{
var timefinished = this.getField("To1").value;
var timestarted = this.getField("From1").
value; var datetimefinished = new Date('1970/01/01' + " " + timefinished);
var datetimestarted = new Date('1970/01/01' + " " + timestarted);
var difflnMilliSeconds = Math.abs(datetimefinished - datetimestarted)/1000;
var hours = Math.floor(difflnMilliSeconds / 3600) % 24;
difflnMilliSeconds -= hours *3600;
var minutes = Math.floor(difflnMilliSeconds / 60) % 60;
difflnMilliSeconds -= minutes * 60;
event.value = hours + "." + minutes ;
}
I am having trouble finding the right script to calculate all totals and how to calculate overtime after 12 am (for Example: From 23:00 till 01:00).
