datepicker - currentMonth problem in jQuery -



datepicker - currentMonth problem in jQuery -

$(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); homecoming [true, "fancy-hover", ""]; daystomark(evt.currentyear+"-"+evt.currentmonth+"-"+evt.currentday); } }); });

but when i'm checking in console year 2011, day 7 , month has problem, show 06 not 07. guess array problem counting 0 how can prepare it?

i tried ->

evt.currentmonth = evt.currentmonth + 1

but no result.

thanks in advance

months in javascript 0 indexed. hence jan = 0 dec = 11

i presume you'd best add together +1 line:

daystomark(evt.currentyear+"-"+evt.currentmonth+"-"+evt.currentday);

like somehow:

var template = '{{year}}-{{month}}-{{day}}'; daystomark( template.replace(/{{year}}/, evt.currentyear).replace(/{{month}}/, number(evt.currentmonth) + 1).replace(/{{day}}/, evt.currentday));

jquery datepicker

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -