is there a way to have all the days of a month or of a year? I am looking for this in order to disable some specific days in a datepicker, i would have a page in the back-of
Here's a loopp that runs through each month to determine the last day of that month. Javascript Date object indexes months starting at zero and if you set the day to zero it reverts back to last day of prior month. Handy for determining leap year last day for February
Date( 2012, 12, 0) will return Dec 31, 2012
Date (2012,0,0) will return Dec 31,2011
and the all important one to figure out is February with
Date ( 2012,3,0) Returns Feb 29 since leap year this year
var mos=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec']
for (i = 0; i < 12; i++) {
var lastDate = new Date(2012, i+1, 0);
$('body').append('Last day of ' + mos[i] + ' is ' + lastDate.getDate()+'
')
}
DEMO: http://jsfiddle.net/5k8sn/1/