Feedback on: irt.org FAQ Knowledge Base Q533
Comments:
Here is an example on how to use the script
<form>
<script>
function days_in_month (year, month) {
return 32 - new Date(year, month, 32).getDate();
}
now = new Date();
daysInMonth = days_in_month(now.getFullYear(),now.getMonth());
txt='<select name="days">';
for (i=1;i<=daysInMonth;i++) txt += '
Worth:
Very worth reading
Comments:
Very cool. But unless I am missing something the day number is zero based. ie: February is "1"
THANX
Worth:
Not worth reading
Length:
Too short
Comments:
Hey!What value does newdate have?! Are the variables being multiplied by newdate then added together or are they being manipulated on some other way?! What language is this written in?! What is the point in posting this without any type of explanation. Does the individual who posted this think everyone has the same knowledge as they? Or is it if they don't already know then they have no business looking here anyway?! If this is a fair sample of your database I propose that it must be a usless waste of storage space!!!!!!!!
Technical:
Not technical enough
Comments:
It is a clever peice of code, but it looks like it is using a so called BUG in the Date() object. Ideally if you pass day as 32 it should give you error. Think when this bug is fixed and your program will stop working; you will have tough time finding this error.
Worth:
Very worth reading
Length:
Just right
Technical:
Just right
Comments:
Why not try
var date = new Date();
date.setMonth(2,0);
var numberOfDaysInJanuary = date.getDate();
Worth:
Worth reading
Length:
Just right
Technical:
Just right
Comments:
Here's a safer method:
function daysInMonth(dt) {
var endNextMonth = new Date(dt);
endNextMonth.setDate(1);
endNextMonth.setMonth(dt.getMonth() + 1);
endNextMonth.setDate(0);
var daysInEndMonth = endNextMonth.getDate();
return daysInEndMonth;
}
Worth:
Very worth reading
Length:
Just right
Technical:
Just right
Comments:
Excellent, short and precise