Checking day of the month and year giving me incorrect results
<p>I am using the below code to check the day of the month but it is not working. Please help me on this  </p>

<pre><code>  function daysInMonth(month, year) {
     var length =  new Date(year, month, 0).getDate();
     for(var i = 1; i &lt; = length; i++)
     {
         console.log(new Date(year,month,i).getDay());
     }
  };
</code></pre>

<p><a href="http://jsfiddle.net/PCjd8/1/" rel="nofollow">here</a> is the fiddle. It returns me incorrect results..</p>
