Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript getDay returning incorrect values for April, June, September, November
    primarykey
    data
    text
    <p>I'm using this script located here: <a href="http://www.javascriptkit.com/script/script2/dyndateselector.shtml" rel="noreferrer">http://www.javascriptkit.com/script/script2/dyndateselector.shtml</a></p> <p>If you try it, and go to any of April, June, September or November, you will notice that the day of the week columns are incorrect. Here's a list of incorrect data (the x starts y stuff is showing the following month.)</p> <p>Bugged months: 4/April (starts Sunday instead of Friday) May starts Sunday</p> <p>6/June (starts Friday instead of Wednesday) July starts Friday</p> <p>9/September (starts Saturday instead of Thursday) October starts Saturday</p> <p>11/November (starts Thursday instead of Tuesday) December starts Thursday</p> <p>You'll notice that every bugged month is starting with the day of the following month, yet all the other months seem to be correct.</p> <p>I can't find anything on this problem. Anyone able to help? The actual Javascript alone can be found here, and the getDay() method occurs on line 125: <a href="http://pastebin.com/0zuBYrzv" rel="noreferrer">http://pastebin.com/0zuBYrzv</a></p> <p>I've tested in both Firefox and Chrome.</p> <p>Here's some very simple code to demonstrate the issue:</p> <pre><code>&lt;script&gt; var d = new Date(); d.setMonth(5); d.setFullYear(2011); d.setDate(1); alert(d.getDay()); &lt;/script&gt; </code></pre> <p>This will create an alert with the message "5", meaning Friday (5+1 = 6, Friday is the 6th day of the week,) when in fact Wednesday is the start of the week.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload