Week No. 1 - week from the first Thursday.
Here is the function to get any day:
var w2date = function(year, wn, dayNb){
var j10 = new Date( year,0,10,12,0,0),
j4 = new Date( year,0,4,12,0,0),
mon1 = j4.getTime() - j10.getDay() * 86400000;
return new Date(mon1 + ((wn - 1) * 7 + dayNb) * 86400000);
};
console.log(w2date(2010, 1, 4));
the number of weeks starts from 1 to 52 or 53, it depends on the year.
For day numbers, 0 is Monday, 1 is Tuesday, ... and 4 is Friday.
source
share