title: Difference between two dates in minute, hours javascript
body: <p>I want to find difference between two dates. I have tried this code but it gives me wrong values. I want get total minutes between two dates, so I am converting hours to minutes and adding to minutes.</p>
  
  <pre><code>var hourDiff = timeEnd - timeStart;
  var diffHrs = Math.round((hourDiff % 86400000) / 3600000);
  var diffMins = Math.round(((hourDiff % 86400000) % 3600000) / 60000);
  diffMins = diffMins + (diffHrs * 60);
  </code></pre>
  
  <p>Here <code>timeEnd</code> is <code>Mon Jan 01 2007 11:30:00 GMT+0530 (India Standard Time)</code>,</p>
  
  <p>and <code>timeStart</code> is <code>Mon Jan 01 2007 11:00:00 GMT+0530 (India Standard Time)</code>.</p>
  
  <p>Here if hours difference I am getting <code>1</code>, it should be <code>0</code> and minutes I am getting <code>30</code> that is right. But hours should be <code>0</code>. Am I doing something wrong here?</p>