How to get the current day of year in TypeScript

1 Answer

0 votes
const date: any = new Date();

const datestartyear: any = new Date(date.getFullYear(), 0, 0); 

const dayOfYear: any = Math.floor((date - datestartyear) / (1000 * 60 * 60 * 24));

console.log(dayOfYear); 




/*
run:

356

*/

 



answered Dec 22, 2022 by avibootz
edited Dec 23, 2022 by avibootz
...