Today is the 31st of January. When you d.setMonth(1);
you are trying to set the date to the 31st of February. Since this date doesn't exist, it falls over to the 3rd of March.
Set the whole date when you initialise the object, don't try to change it piecemeal.