JSFiddle - React, Tailwind, and code Playground
by brigand
JavaScript
function jday(date) {
const firstDay = new Date(date.getUTCFullYear(), 0, 0);
const day = `${Math.floor((date - firstDay) / (24 * 60 * 60 * 1000))}`;
return day.padStart(3, '0');
}
console.log(jday(new Date()))
console.log(jday(new Date('2018-07-08')))