I have this function
function calculateTimes(firstDate, firstTime, secondDate, secondTime){
var fDate = firstDate+" "+firstTime;
var sDate = secondDate+" "+secondTime;
var firstDateFull = new Date(fDate);
var secondDateFull = new Date(sDate);
var diff = secondDateFull - firstDateFull;
var diffSeconds = diff / 1000;
var HH = Math.floor(diffSeconds / 3600);
var MM = Math.floor((diffSeconds % 3600) / 60);
var SS = "00";
var formatted = ((HH < 10) ? ("0" + HH) : HH) + ":" + ((MM < 10) ? ("0" + MM) : MM);
return formatted;
}
Which I use like this
$('#uoc-r4disDate-fld, #uoc-r4disTime-fld, #uoc-disDate-fld, #uoc-disTime-fld').on('change', function() {
$("#uoc-delay-fld").val(calculateTimes($("#uoc-r4disDate-fld").val(), $("#uoc-r4disTime-fld").val(), $("#uoc-disDate-fld").val(), $("#uoc-disTime-fld").val()));
});
My problem is that this is a delay field and the hours can run up past 24h. Is there a way to make a Time field accept more than 24h in the hour in JavaScript? The database im using ( 4th Dimension ) can accept hours above 24h for exactly this type of situation I guess.
So, it need to be able to display - 26:34
. Elapsed time in time format, like a stopwatch.