Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function daysInMonth(month,year) {
- return new Date(year, month, 0).getDate();
- }
- daysInMonth(7,2009); //31
- daysInMonth(2,2009); //28
- daysInMonth(2,2008); //29
- function daysInMonth(Month, Year)
- {
- return 32 - new Date(Year, Month, 32).getDate();
- }
- daysInMonth(7,2009)
- >>> 31
- Date.prototype.monthDays= function(){
- var d= new Date(this.getFullYear(), this.getMonth()+1, 0);
- return d.getDate();
- }
- Date.getDaysInMonth(2009, 9)
- // pass in any date as parameter anyDateInMonth
- function daysInMonth(anyDateInMonth) {
- return new Date(anyDateInMonth.getYear(),
- ++anyDateInMonth.getMonth(),
- 0).getDate();}
- function daysInMonth(month,year) {
- return new Date(year, month, 0).getDate();
- }
Add Comment
Please, Sign In to add comment