title: Receiving "Invalid Date" when attempting to get user input with JavaScript
body: <p>So, I am trying to calculate the difference between two dates entered by the user with JavaScript; however, I keep receiving InvalidDate. Any help would be appreciated.</p>
  <p>Here is my code:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Assignment Calculator&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;Assignment Calculator&lt;/h1&gt;
      
  &lt;form&gt;
      &lt;label for=&quot;StartDate&quot;&gt;Date to Start:&lt;/label&gt;
      &lt;input id=&quot;StartDate&quot; name=&quot;StartDate&quot; type=&quot;date&quot;/&gt;
  
      &lt;label for=&quot;DueDate&quot;&gt;Due Date:&lt;/label&gt; 
      &lt;input id=&quot;DueDate&quot; name=&quot;DueDate&quot; type=&quot;date&quot;/&gt;
      
      &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; onclick=&quot;displayDates()&quot;&gt;
  &lt;/form&gt;
      
  &lt;script type = &quot;text/javascript&quot; &gt;
  
  // Get start date and due date 
  
  var startInput = document.getElementById(&quot;StartDate&quot;).value;
  var dueInput = document.getElementById(&quot;DueDate&quot;).value;
      
  var startDate = new Date(startInput);
  var dueDate = new Date(dueInput);
  
  // To calculate the time difference of two dates
  var DifferenceInTime = dueDate.getTime() - startDate.getTime();
  
  // To calculate the no. of days between two dates
  var DifferenceInDays = DifferenceInTime / (1000 * 3600 * 24);
  
  function displayDates() {
  //To display the of days a student has to work on the assignment (result)
  document.write(&quot;Start your assignment by &quot; + startDate + &quot;.&lt;br&gt;&quot;
              + &quot;Finish your assignment by &quot; + dueDate + &quot;.&lt;br&gt; &quot;
              + &quot;You must complete your assignment in this many days: &quot; + DifferenceInDays + &quot;.&quot;);
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>