title: Determining Date Equality in Javascript
body: <p>I need to find out if two dates the user selects are the same in Javascript. The dates are passed to this function in a String ("xx/xx/xxxx").That is all the granularity I need.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>        var valid = true;
      var d1 = new Date($('#datein').val());
      var d2 = new Date($('#dateout').val());
      alert(d1+"\n"+d2);
      if(d1 &gt; d2) {
          alert("Your check out date must be after your check in date.");
          valid = false;
      } else if(d1 == d2) {
          alert("You cannot check out on the same day you check in.");
          valid = false;
      }
  </code></pre>
  
  <p>The javascript alert after converting the dates to objects looks like this:</p>
  
  <p>Tue Jan 25 2011 00:00:00 GMT-0800 (Pacific Standard Time)</p>
  
  <p>Tue Jan 25 2011 00:00:00 GMT-0800 (Pacific Standard Time)</p>
  
  <p>The test to determine if date 1 is greater than date 2 works. But using the == or === operators do not change valid to false.</p>