$(function() {
$('#datepicker').datepicker({
beforeShowDay: daysToMark,
onSelect: function(date,evt){
if (evt.currentMonth < 10){
evt.currentMonth = "0"+evt.currentMonth;
}
if (evt.currentDay < 10){
evt.currentDay = "0"+evt.currentDay;
}
//var Month = evt.currentMonth;
//console.log(nMonth);
return [true, "fancy-hover", ""];
daysToMark(evt.currentYear+"-"+evt.currentMonth+"-"+evt.currentDay);
}
});
});
but when i’m checking in console year is 2011, day is 7 and month has a problem, it show 06 not 07. i guess it is an array problem counting from 0 but how can i fix it?
I tried this ->
evt.currentMonth = evt.currentMonth + 1
but with no result.
thanks in advance
Months in JavaScript are zero indexed. Hence January = 0 December = 11
I presume you’d be best to add your +1 to this line:
like this somehow: