For Example:
StartTime = \'00:10\';
EndTIme = \'01:20\';
These variables are string
Question: How can I Subtract them and returning
If you're going to be doing a lot of date/time manipulation, it's worth checking out date.js.
However, if you're just trying to solve this one problem, here's an algorithm off the top of my head.
(1)Parse start/end values to get hours and minutes, (2)Convert hours to minutes, (3)Subtract
function DifferenceInMinutes(start, end) {
var totalMinutes = function(value) {
var match = (/(\d{1,2}):(\d{1,2})/g).exec(value);
return (Number(match[1]) * 60) + Number(match[2]);
}
return totalMinutes(end) - totalMinutes(start);
}