calculate time difference in HH:mm format

You can just substract two Dates from one another, the result will be the difference in milliseconds.

From the Mozilla Developer Network:

// using static methods
var start = Date.now();
// the event you'd like to time goes here:
doSomethingForALongTime();
var end = Date.now();
var elapsed = end - start; // time in milliseconds

Since Date has a constructor that accepts milliseconds as an argument, you can re-convert this to a Date by just doing

var difference = new Date(elapsed);
//If you really want the hours/minutes, 
//Date has functions for that too:
var diff_hours = difference.getHours();
var diff_mins = difference.getMinutes();

Something like this:

​var t1 = '12:04'.split(':'), t2 = '3:45'​​​​​​​.split(':');
var d1 = new​ Date(0, 0, 0, t1[0], t1[1]),
    d2 = new Date(0, 0, 0, t2[0], t2[1]);
var diff = new Date(d1 - d2);