Dec 26, 2000 #1 mitch77 Programmer Nov 16, 2000 42 PT there are any function in javascript, to count the number of days in a month? thanks, Mitch Jeffers
Dec 26, 2000 #2 jaredn Programmer Sep 1, 1999 1,506 US I don't think there is a native method to complete this. jared@aauser.com Upvote 0 Downvote
Dec 26, 2000 1 #3 rbobbitt Programmer Aug 17, 2000 566 US I don't think javascript supplies a method for this either, but you can write your own. For example: function isLeapYear { return (y%4==0 && y%100!=0) || y%400==0; } function daysInMonth(m,y) { if (m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12) { return 31; } else if (m==4 || m==6 || m==9 || m==11) { return 30; } else { return isLeapYear ? 29 : 28; } } // Get # of days in February for the current year var md=daysInMonth(2,new Date().getYear()); HTH, Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts Upvote 0 Downvote
I don't think javascript supplies a method for this either, but you can write your own. For example: function isLeapYear { return (y%4==0 && y%100!=0) || y%400==0; } function daysInMonth(m,y) { if (m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12) { return 31; } else if (m==4 || m==6 || m==9 || m==11) { return 30; } else { return isLeapYear ? 29 : 28; } } // Get # of days in February for the current year var md=daysInMonth(2,new Date().getYear()); HTH, Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts