title: difference between 2 dates
body: <p>I have to simply calculate difference between two dates, and display it as integer but my code below gives errors if there are large amount of dates (more than 26) in between 2 dates, as well as if there is a date "31st" of a month in between 2 dates.</p>
  
  <p>Can not find whats wrong with my code...?</p>
  
  <p>The values of <code>'ires_sakuma_datums'</code> and <code>'ires_beigu_datums'</code> are set by jquery calendar picker and are displayed in the format e.g. <code>25-08-2012</code> and <code>17-09-2012</code> respectively and the result should be displayed into id <code>'dienu_skaits'</code> </p>
  
  <p>Example <code>'ires_sakuma_datums'</code> is set to <code>28-08-2012</code> and <code>'ires_beigu_datums'</code> is set to <code>29-09-2012</code> and it results into <code>31.041666666666668</code> although I would expect to result into <code>32</code></p>
  
  <pre><code>   function getDays()
      {
          var x = document.getElementById('ires_sakuma_datums').value;
          var y = document.getElementById('ires_beigu_datums').value;
  
          //assuming that the delimiter for dt time picker is a '-'.
          var arr1 = x.split('-');
          var arr2 = y.split('-');
          var dt1 = new Date();
          dt1.setFullYear(arr1[2], arr1[1], arr1[0]);
          var dt2 = new Date();
          dt2.setFullYear(arr2[2], arr2[1], arr2[0]);
  
          document.getElementById('dienu_skaits').value = (dt2.valueOf() - dt1.valueOf()) / (60 * 60 * 24 * 1000);
  
  document.forms['test'].elements['dienu_skaits'].focus();
      }
  </code></pre>