1You can just subtract the hours right away doing it this way
2
3var valuestart = $("select[name='timestart']").val();
4var valuestop = $("select[name='timestop']").val();
5
6//create date format
7var timeStart = new Date("01/01/2007 " + valuestart).getHours();
8var timeEnd = new Date("01/01/2007 " + valuestop).getHours();
9
10var hourDiff = timeEnd - timeStart;
11Here's the working fiddle http://jsfiddle.net/VnwF7/4/
12
13UPDATE - to calculate if we are including the next day. Just add the following if block
14
15 if (hourDiff < 0) {
16 hourDiff = 24 + hourDiff;
17 }
18http://jsfiddle.net/gfvhqat9/