Cremator
01-29-2012, 12:00 AM
Snippet to get the number of days,
Date.prototype.daysInMonth=function(mth,yr){
yr = yr || this.getFullYear();
mth = mth || this.getMonth();
return 32 - new Date(yr, mth, 32).getDate();
}
alert( new Date().daysInMonth() );
pass month & year to get the days in a month for that year.
pass month to get the number of days in the month in the current year
pass no parameters to get the number of days in the current month in the current year.
or
Date.prototype.daysInMonthPartRFC=function(partRfc){
partRfc = (partRfc)? partRfc+"/"+32 : [this.getFullYear(),this.getMonth(),32].join("/");
return 32 - new Date(partRfc).getDate();
}
alert( new Date().daysInMonthPartRFC("2012/0") );
pass a part date string made up of the year and javascript month separated by a slash or pass no argument to get days in current month in current year.
months being passed will be JavaScript months, 0 to 11.
Date.prototype.daysInMonth=function(mth,yr){
yr = yr || this.getFullYear();
mth = mth || this.getMonth();
return 32 - new Date(yr, mth, 32).getDate();
}
alert( new Date().daysInMonth() );
pass month & year to get the days in a month for that year.
pass month to get the number of days in the month in the current year
pass no parameters to get the number of days in the current month in the current year.
or
Date.prototype.daysInMonthPartRFC=function(partRfc){
partRfc = (partRfc)? partRfc+"/"+32 : [this.getFullYear(),this.getMonth(),32].join("/");
return 32 - new Date(partRfc).getDate();
}
alert( new Date().daysInMonthPartRFC("2012/0") );
pass a part date string made up of the year and javascript month separated by a slash or pass no argument to get days in current month in current year.
months being passed will be JavaScript months, 0 to 11.