mt**@mtekusa.com wrote:
I am using this code to get the day number of the week:
var numbers = entered.split('/');
var daynum = (new Date(Date.UTC(numbers[2] -
1900,numbers[0],numbers[1]-1))).getUTCDay();
Date comes in as MM/DD/YYYY
This works fine, as long as I am looking in the same month within a 3
week period. But choose March 1st (Saturday) or any other day in
another month, and the day number is wrong.
You are doing two nonsensical subtractions, and you have mixed up the
arguments. First, there is no need and it does not make sense to subtract
1900 from the year value. Second, the second argument of Date.UTC() is the
month value; you have to subtract 1 *there*, and _not_ from the value for
the third argument (which is the day-of-month).
Otherwise on 2008-03-01 CE ("3/1/2008") you would end up with
var daynum = (new Date(Date.UTC(108, 3, 0)).getUTCDay();
The string representation of `new Date(Date.UTC(108, 3, 0))' is "Sun Apr 01
0108 02:00:00 GMT+0200" in my Firefox 2.0.0.12; probably not what you want ;-)
6 hours I've been at this....any help would be greatly appreciated. I
just need the day number of the week.
If you make the suggested corrections, it should work.
PointedEars