I have some code on a website which isn't playing by 'my' rules.
var g=new Date(d,m,y);
var weekday=new Array(7);
<input type="date" id="date" name="date" value="" onchange="do_date()" style="width:150px;" />
wd returns 5 for Friday 5th July 2013, but on Monday the 8th July 2013 it returns 2 in fact consecutive days from the 1st July to the 31st of July 2013 return the following:
which displays the days in a very strange order
Wednesday,Thursday,Friday,Saturday,Sunday, Monday,Tuesday etc.
I have obviously done something wrong, but for the life of me I can not work it out.
If anyone could point me in the right direction, I would appreciate it :)
You are creating wrong the date variable. Look the syntax of the constructor (from doc):
new Date(); new Date(value); new Date(dateString); new Date(year, month, day [hour, minute, second, millisecond]);
Notice that the month has to be a value between 0 and 11. So in your code:
var g=new Date(y, m - 1, d);