JSFiddle - React, Tailwind, and code Playground
by mlms13
JavaScript
Date.prototype.getWeek = function() {
var janFirst = new Date(this.getFullYear(), 0, 1),
dayOfYear = Math.ceil((this - janFirst) / 86400000),
firstWeekStart = janFirst.getDay() === 0 ? janFirst.getDay() : 8 - janFirst.getDay(); // Not sure this works
return Math.ceil((dayOfYear - firstWeekStart) / 7);
};
var d = new Date();
document.writeln(d.getWeek());