wrong date created with Javascript
<p>I have a problem that seems so senseless that I'm sure I'm missing something really stupid.
I have the following Javascript function that validates a date:</p>

<pre><code>function validateDate(date){
    var re = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
    if(!re.test(date))
        return false;

    var separator = (date.indexOf("/") != -1) ? "/" : "-";
    var aux = date.split(separator);
    var day = parseInt(aux[0]);
    var month = parseInt(aux[1]);
    var year = parseInt(aux[2]);
    alert(aux[0]+" "+aux[1]+" "+aux[2]);
    var dateTest = new Date(year,month-1,day);
    alert(dateTest); //2nd alert
    if(dateTest.getDate() != day)
        return false;
    if(dateTest.getMonth()+1!= month)
        return false;
    if(dateTest.getFullYear() != year)
        return false;

    return true;    
}
</code></pre>

<p>the first alert always shows the correct values.
if the incoming date is for example <code>05/07/2011</code>, everything works fine. The second alert shows <code>"Tue Jul 5 00:00:00 UTC+0200 2011"</code> which is right.
but now, if i change the date month to august or september, the created date is wrong. for example, with date <code>05/08/2011</code>, the second alert will show <code>"Sun Dec 5 00:00:00 UTC+0100 2010"</code>.</p>

<p>anyone knows what could be happening??</p>
