Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Week number (ISO 8601)
- Date.prototype.getWeek = function () {
- // Copies this date
- var s = new Date(+this);
- // Set day to the first thursday of the year
- s.setDate(s.getDate() + 4 - (s.getDay() || 7));
- // return the weeknumber of this date
- return ~~(~~((s.getTime() - new Date(s.getFullYear(), 0, 1)) / 8.64e7) / 7) + 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement