Serious Day of Week problem

# Thread: Serious Day of Week problem

1. Ben Roy Guest

## Serious Day of Week problem

I am beyond baffled by what I&#039;m seeing here. I&#039;m really hoping that I&#039;m just doing something stupid and you guys can straighten me out.<BR><BR>myDate = new Date(2001, 3, 24);<BR>myDay = myDate.getDay();<BR><BR>This returns a 2, which stands for Tuesday. 3/24/2001 is a Saturday. If I do:<BR><BR>Alert(myDate.getDate() + "/" + myDate.getMonth() + "/" + myDate.getYear())<BR><BR>it spits out 3/24/2001 as expected, so it seems to be creating the date correctly. Oh yeah, one more thing. If you set it to 2/24/2001 it works correctly!

2. Dan Evans Guest

## RE: Serious Day of Week problem

I suspect your problem is that you haven&#039;t accounted for the month index beginning at 0, i.e. 3/24/2001 = 24th of APRIL, 2001 (Which is indeed a Tuesday).<BR><BR>That&#039;s why you&#039;re getting the right value for 2/24/2001 - The 2 stands for March :o)<BR><BR>-Dan Evans

3. Ben Roy Guest

## RE: Serious Day of Week problem

Wow ****. Nice one Dan. You&#039;ve got no idea how big a deal figuring this out is. =) You know the funny part is I was reading through all the docs on Date and it&#039;s methods, constructors, etc., and it never occurred to me that someone would ever think to make it take 0-11 for the month. Funny that the day is 1-31, and the year is the year, not year-1. Well, always off by one. Thanks a lot!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•