Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function daysInMonth(iMonth, iYear) {
- return 32 - new Date(iYear, iMonth, 32).getDate();
- }
- function daysInMonth(month,year) {
- return new Date(year, month, 0).getDate();
- }
- var daysInMonth = (function() {
- var cache = {};
- return function(month, year) {
- var entry = year + '-' + month;
- if (cache[entry]) return cache[entry];
- return cache[entry] = new Date(year, month, 0).getDate();
- }
- })();
- function numberOfDays(iMonth, iYear) {
- var myDate = new Date(iYear, iMonth + 1, 1); //find the fist day of next month
- var newDate = new Date(myDate - 1); //find the last day
- return newDate.getDate(); //return # of days in this month
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement