Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. function daysInMonth(iMonth, iYear) {
  2. return 32 - new Date(iYear, iMonth, 32).getDate();
  3. }
  4.  
  5. function daysInMonth(month,year) {
  6. return new Date(year, month, 0).getDate();
  7. }
  8.  
  9. var daysInMonth = (function() {
  10. var cache = {};
  11. return function(month, year) {
  12. var entry = year + '-' + month;
  13.  
  14. if (cache[entry]) return cache[entry];
  15.  
  16. return cache[entry] = new Date(year, month, 0).getDate();
  17. }
  18. })();
  19.  
  20. function numberOfDays(iMonth, iYear) {
  21. var myDate = new Date(iYear, iMonth + 1, 1); //find the fist day of next month
  22. var newDate = new Date(myDate - 1); //find the last day
  23. return newDate.getDate(); //return # of days in this month
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement