41
rated 0 times
[
42]
[
1]
/ answers: 1 / hits: 25043
/ 11 Years ago, tue, june 11, 2013, 12:00:00
I created this function to increment a date (for a jQuery UI Datepicker):
function addDay(date) {
var moreDay = new Date();
var decomposed = date.split(-);
var act = new Date(decomposed[2], decomposed[1], decomposed[0]);
moreDay.setDate(act.getDate()+1);
return moreDay;
}
So, it scomposes the date (ex: 12-06-2013 (dd-mm-YYYY)) and put the values into a new Date, after that it addes a day. It works, but the month not change. Example, I changed the function into this:
function addDay() {
var moreDay = new Date();
var act = new Date(2013, 7, 3);
moreDay.setDate(act.getDate()+1);
alert(moreDay);
}
And it returns Jun 4th 2013.. How it's possible?
More From » javascript