I have tried to get the time difference between 2 different times and i am getting it correctly for hours and minutes. But if the second is greater than the first it will getting the problem. The time is displaying with negative data.
for example
Start time : 00:02:59
End time : 00:05:28
If i getting the difference between start and end time
00:05:28 - 00:02:59 = 00:3:-31
Which is not a correct value. I'm using the following script for getting this value.
var start_time = $("#startTime").val();
var end_time = $("#endTime").val();
var startHour = new Date("01/01/2007 " + start_time).getHours();
var endHour = new Date("01/01/2007 " + end_time).getHours();
var startMins = new Date("01/01/2007 " + start_time).getMinutes();
var endMins = new Date("01/01/2007 " + end_time).getMinutes();
var startSecs = new Date("01/01/2007 " + start_time).getSeconds();
var endSecs = new Date("01/01/2007 " + end_time).getSeconds();
var secDiff = endSecs - startSecs;
var minDiff = endMins - startMins;
var hrDiff = endHour - startHour;
alert(hrDiff+":"+minDiff+":"+secDiff);
anyone please tell me how to get the time difference between two times correctly even considering with seconds