How to subtract military time in JavaScript/JQuery? : I have two time values that should subtract and output the difference in hours. For example I get the values in this format:

    0530-2400

That value is string, I guess that converting to JavaScript date object is the first step. Here is what I have so far:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

    var time = "0530-2400",
        arr = [];
    arr = time.split('-');

    var dateObj = new Date(),
        hours1 = dateObj.setHours(Number(arr[0].substring(0, 2))),
        hours2 = dateObj.setHourse(Number(arr[1].substring(0, 2))),
        minutes1 = dateObj.setMinutes(Number(arr[0].substring(2, 4))),
        minutes2 = dateObj.setMinutes(Number(arr[1].substring(2, 4)));
        
    console.log(hours1);
    console.log(minutes1);
    console.log(hours2);
    console.log(minutes2);

<!-- end snippet -->

The output for the time I showed above should be `18.5` hours. If we subtract `24-5.5(530) = 18.5`

The increments are always on `15,30 or 45` minutes. Is there a good way to convert string and then do the math in JS? 