When I do the following (the date represents 2/1/2004)
Which date is that? Second of January or first of February? (Yes, I
know, but only because your remaning text is less ambiguous than this
explanatory note
Did you try it three days ago? It would have worked then.
getDay returns
1, and it should be returning 0. It's the only month for which we see
this behavior.
Tomorrow (on the 31th) you will see it for all 30 day months too.
Have you tried debugging at all? Inserting alert statments between
each line to see the current value of oDate? It would be informative.
Here oDate is 31th of January 2004 for me now.
No change
Now you set the month to February. That means that the date is now
supposed to be the 31th of February 2004 . Since that doesn't exist,
the Date-object autocorrects it to the 2rd of March 2004 (two days
after the 29th of February)
Now it is 1st of March 2004 .
1st of March 2004 is a Monday.
Is this a know problem or an expected result?
Expected result. Never assign parts of a date separatly, especially
date in month and month. Use
oDate.setMonth(1,1);
or better yet
oDate.setYear(2004,1,1);
(better because it won't fail on the 29th of February, like, e.g.,
var myDate = new Date(2003,1,1); // some date in 2003
myDate.setMonth(1,29);
myDate.setYear(2004);
result: 1st of March 2004)
/L