jquery - get all the dates that fall between two dates -


i have problem user selects range of dates. need find out dates fall between 2 selected dates. they're coming in via jquery simple

$('#from').val()+"-"+$('#to').val();

they're coming jqueryui datepicker , like

08/07/2013 - 08/09/2012

but can't figure out how step through dates , determine days in in between. need specific dates, becomes complicated things end of month , different number of days in each month. in specific example, i'd need get

08/07/2013, 08/08/2013, 08/09/2013

you can grab values date pickers using getdate method, since return date object. then, starting @ start date increment "current" date 1 day , add array until current date same end date.

note you'll need create new date() when adding between array, or else referencing currentdate object , values same.

working demo

var start = $("#from").datepicker("getdate"),     end = $("#to").datepicker("getdate"),     currentdate = new date(start.gettime()),     between = [] ;  while (currentdate <= end) {     between.push(new date(currentdate));     currentdate.setdate(currentdate.getdate() + 1); } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -