The results I am trying to get is:

1:00 to 3:00 equals 2

22:00 to 1:00 equals 3

etc.

if ((this.getField("End time").value.length == 0) || (this.getField("Start time").value.length == 0)) {

event.value = " 24.0";

}

else{

var time1 = this.getField("End Time").value;

var time2 = this.getField("Start Time").value;

// convert to date

var datetime1 = new Date('1970/01/01 ' + time1);

var datetime2 = new Date('1970/01/01 ' + time2);

var diffInMilliSeconds = Math.abs(datetime1 - datetime2) / 1000;

// calculate hours

var hours = Math.floor(diffInMilliSeconds / 3600) % 24;

diffInMilliSeconds -= hours * 3600;

// calculate minutes

var minutes = Math.floor(diffInMilliSeconds / 60) % 60;

diffInMilliSeconds -= minutes * 60;

// set field value to the difference

event.value =hours + ":" +minutes;

}

var result;

if (Time1 < Time2) {

var minutesPerDay = 24*60;

result = minutesPerDay - Time2; // Minutes till midnight

result += Time2; // Minutes in the next day

} else {

result = Time1 - Time2;

}

var minutesElapsed = result % 60;

var hoursElapsed = (result - minutesElapsed) / 60;

alert ( "Elapsed Time : " + hoursElapsed + ":" + (minutesElapsed < 10 ?

'0'+minutesElapsed : minutesElapsed) ) ;