title: javascript calculating difference between two dates gives me NaN
body: <pre><code>var startDate = new Date($('#startdate').val());
  var endDate = new Date($('enddate').val());
  var msPerDay = 1000*60*60*24;
  var diff =  Math.floor(startDate.getTime() - endDate.getTime());
  $('#period').text(diff/msPerDay);
  </code></pre>
  
  <p>This is my code, it's pretty much based on other answers on SO. I can't seem to figure out what I'm doing wrong here ?</p>