I have some trouble with date manipulation in Javascript.
I have one variable which is firstDay
, that's date that I'm operating on.
To firstDay
I add X
days from one variable, and Y
days from another:
var from_date = new Date(firstDay); // firstDay is a string with date: 2012/07/28
var to_date = new Date(firstDay);
var X = 1;
var Y = 5;
from_date.setDate(from_date.getDate() + X);
to_date.setDate(to_date.getDate() + Y);
So from_date
now contains date 29.07.2012 and to_date is 02.08.2012. I don't know why date changes properly, but months stay the same.
Where I make something wrong?