title: JavaScript Date Comparisons Don't Equal
body: <p>I've tried searching for people with similar questions, but haven't found anything.</p>
  
  <p>I have two dates in JavaScript, both set to the same value... Equality Testing fails on ==, but >= and &lt;= evaluate true.</p>
  
  <p>Below is the code I have in play:</p>
  
  <pre><code>var startDate = new Date( 2011, 7, 30, 0, 0, 0, 0 );
  
  var dt = new Date( 2011, 7, 30, 0, 0, 0, 0 );
  
  if( startDate == dt )
      document.write('They Equal&lt;br /&gt;');
  
  if( startDate &gt; dt )
      document.write('Start Date is &gt; dt&lt;br /&gt;');
  
  if( startDate &gt;= dt )
      document.write('Start Date is &gt;= dt&lt;br /&gt;');
  
  if( startDate &lt; dt )
      document.write('Start Date is &lt; dt&lt;br /&gt;');
  
  if( startDate &lt;= dt )
      document.write('Start Date is &lt;= dt&lt;br /&gt;');
  
  if( dt == startDate )
      document.write('They Equal&lt;br /&gt;');
  
  if( dt &gt; startDate )
      document.write('dt &gt; startDate&lt;br /&gt;');
  
  if( dt &gt;= startDate )
      document.write('dt &gt;= Start Date &lt;br /&gt;');
  
  if( dt &lt; startDate )
      document.write('dt &lt; Start Date &lt;br /&gt;');
  
  if( dt &lt;= startDate )
      document.write('dt &lt;= Start Date &lt;br /&gt;');  
  
  document.write( dt );
  document.write( '&lt;br /&gt;');
  document.write( startDate );
  </code></pre>
  
  <p>Has anyone encountered anything like this, or am I doing something fundamentally wrong?</p>
  
  <p>I tested this is Internet Explorer (9), Firefox 5+, and Chrome.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>So two people posted great answers to my problem, and I thank both of you: xdazz and DaveRandom. I had read an earlier post on stackoverflow.com on a similar question and a guy said that date objects could be compared like any others, and any other example I found always did a &lt; or > type of compare, never a full equality so I wasn't able to make the connection as to why I was doing it wrong.</p>
  
  <p>Thanks to you two, and the others that posted similar answers.</p>