title: javascript date subtraction
body: <p>I am looking for a way to do proper subtraction between two javascript Date objects and get the day delta.</p>
  
  <p>This is my approach but it fails for todays date as an input:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function getDayDelta(incomingYear,incomingMonth,incomingDay){
  var incomingDate = new Date(incomingYear,incomingMonth,incomingDay);
  var today = new Date();
  
  var delta = incomingDate - today;
  var resultDate = new Date(delta);
  return resultDate.getDate();
  }
  //works for the future dates:
  alert(getDayDelta(2009,9,10));
  alert(getDayDelta(2009,8,19));
  
  //fails for the today as input, as expected 0 delta,instead gives 31:
  alert(getDayDelta(2009,8,18));
  &lt;/script&gt;
  </code></pre>
  
  <p>What would be a better approach for this ?</p>