I want to calculate the difference between two given times. The times will be given in the format hhmm (eg : 1030).
What would be the best way if I had a start and end time to calculate the difference between the two (answer in minutes)?
I thought of something like this but its not right :
say Start = 1030
End = 1145
function Time(which)
{
vala = left(document.myform.End.value,2);
valb = right(document.myform.End.value,2);
valc = left(document.myform.Start.value,2);
vald = right(document.myform.Start.value,2);
document.getElementById("Time").innerHTML = (parseInt(vala) - parseFloat(valc))*60 +(parseInt(valb) - parseFloat(vald));
}
What would be the best way if I had a start and end time to calculate the difference between the two (answer in minutes)?
I thought of something like this but its not right :
say Start = 1030
End = 1145
function Time(which)
{
vala = left(document.myform.End.value,2);
valb = right(document.myform.End.value,2);
valc = left(document.myform.Start.value,2);
vald = right(document.myform.Start.value,2);
document.getElementById("Time").innerHTML = (parseInt(vala) - parseFloat(valc))*60 +(parseInt(valb) - parseFloat(vald));
}