PDA

View Full Version : Subtract one Time String from another


bgmiller
08-09-2002, 09:22 PM
I have two time values in a form where I would like to find the difference between the two:

Time1: 9:00 am
Time2: 1:00 pm
Difference = 4 hours

I'm not sure how to convert the string format of the time into a date format so that I can subtract the two.

Thanks
Brian

nolachrymose
08-09-2002, 11:34 PM
function dateDiff(d1,d2) {
var big=Math.max(d1,d2);
var small=Math.min(d1,d2);
return (big-small)*100*60*60;
}

Hope that helps!

Happy coding! :)