I'm trying to write a script for a form which will calculate the elapsed time between and entry time and exit time. I know this should be easy enough, but I don't want date strings in it and I need the script to read from the entries in the form and return the calculated string to the form before submission to a database.

I know that I should be able to convert the time to milliseconds and do it something like this.

var timeIn = (time1(time.split(':')[0])*3600+time1(time.split(':')[1])*60)*1000);
var timeOut = (time2(time.split(':')[0])*3600+time2(time.split(':')[1]*60)*1000);
var timeEl = timeOut - timeIn;

the hard part is taking it back out to hh:mm format and getting the variables to assign correctly.

So what suggestions are there so I can write this right the first time? (Besides do this in PHP, as I might have to do.)

Thanks in advance for the help.