I have the following code to get the week number when I rpovide a date
Date.prototype.getWeek = function () {
var d = new Date(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate()));
d.setUTCDate(d.getUTCDate() - d.getUTCDay());
var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
return Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
}
when I pass the date 2018-01-01 the weekNumber is given as 53 as january 1st of 2018 lay on the last week of 2017. How can I get the week number by making the year start at january 1st instead of making the the start day of each week is a sunday ?