title: CALCULATING TIME in javascript
body: <p>I am using this formula to calculate time between 2 different fields but result is in whole numbers and I need hours/minutes</p>
  
  <p>time after dateFromString is example</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var date1 = dateFromString(06: 00: 00);
  var date2 = dateFromString(17: 30: 00);
  var hours = Math.abs(date1 - date2) / 36e5;
  return hours;
  
  function dateFromString(isoDateString) {
    var parts = isoDateString.match(/\d+/g);
    var isoTime = Date.UTC(parts[0], parts[1] - 1, parts[2], parts[3], parts[4], parts[5]);
    var isoDate = new Date(isoTime);
    return isoDate;
  }</code></pre>
  </div>
  </div>
  </p>