Thanks @RobG for correcting me. Here is another go at it. I tried it with the time example given and changing both the minutes and hours of both times. I'm sure this isn't the fastest way but it is a homebrew.
var first = "2016-04-15 1230"
var second ="2016-04-15 1210"
var timeDiff = function(x, y) {
// Gets first hours and cuts it out
hrs1 = first.slice(11, 13);
// Gets second hours and cuts it out
hrs2 = second.slice(11, 13);
// Gets the minutes from first time and cuts it out
min1 = first.slice(13,15);
// Gets the minutes from second time and cuts it out
min2 = second.slice(13,15);
// Subtracts and puts the difference of minutes in minDiff variable
var minDiff = min1 - min2;
// Subtracts and puts the difference of hours in hrsDiff variable
var hrsDiff = hrs1 - hrs2;
// If it is negative, make it positive
if(minDiff <0){
minDiff *= -1;
}
if(hrsDiff < 0) {
hrsDiff *= -1;
}
return ["Diff in hrs: " + hrsDiff, "Difference in Minutes: " + minDiff];
}
Returns: ["Diff in hrs: 0", "Difference in Minutes: 20"]
With times: "2016-04-15 1530", and "2016-04-15 1248",
Returns: ["Diff in hrs: 3", "Difference in Minutes: 18"]
Hope this was helpful.