Date object.new Date() and Date.prototype.getFullYear() to get the first day of the year as a Date object.date and divide with the milliseconds in each day to get the result.Math.floor() to appropriately round the resulting day count to an integer.const dayOfYear = date => Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24);
dayOfYear(new Date()); // 272Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️