Here is my JavaScript code snippet:
var earlierdate = new Date(2012, 09, 22);
alert(earlierdate.getDay());
var date2 = new Date('2012, 09, 22');
alert(date2.getDay());
The issue I am facing is that the first alert displays 1 or Monday (incorrect) while the second one displays 6 or Saturday (correct). When I try to use variables instead of hard-coded values like this:
var date1 = new Date(a, b, c);
alert(date1.getDay());
I am unable to figure out the correct syntax. I have tried several variations without success.
Any help would be greatly appreciated. Thank you!