From https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay
The value returned by getDay() is an integer corresponding to the day of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.
From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Syntax can be used as new Date(dateString);
dateString
String value representing a date. The string should be in a format recognized by the Date.parse() method (IETF-compliant RFC 2822 timestamps and also a version of ISO8601).
Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies.
This being said, it is (1) to be expected that Tuesday is represented by the number 2, and (2) disencouraged to use new Date(dateString)
. A better option would be parsing the date input's value into year/month/day and using the new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);
syntax.