Get the difference between two dates, in the most convenient unit
Use getTime instead of the UTC transformation it'll return the timeStamp.

So your diff would be:

b.getTime() - a.getTime()


This will give you the milliseconds if you want the seconds you would divide it by 1000 so you would get:

var secondsDiff = (b.getTIme() - a.getTime())/1000


Then for the return 

if (secondsDiff &gt; 86400)  { 
 return Math.floor(secondsDiff/86400) + ' D'
}
if (secondsDiff &gt; 3600)  { 
 return Math.floor(secondsDiff/3600) + ' h'
}
if (secondsDiff &gt; 60)  { 
 return Math.floor(secondsDiff/60) + ' min'
}
if (secondsDiff &gt; 0) { 
 return secondsDiff + ' sec'
}