const getWeekOfYear = (date: Date): number => {
const startOfYear = new Date(date.getFullYear(), 0, 1);
const days = Math.floor(
(date.getTime() - startOfYear.getTime()) / (24 * 60 * 60 * 1000)
);
return Math.ceil((days + startOfYear.getDay() + 1) / 7);
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter