How to convert day of year to date in Node.js

1 Answer

0 votes
function dayToDate(year, day) {
  	return new Date(year, 0, day);
}

console.log(dayToDate(2022, 17).toDateString());

console.log(dayToDate(2022, 33).toDateString());

console.log(dayToDate(2022, 71).toDateString());


  
  
  
  
/*
run:
  
Mon Jan 17 2022
Wed Feb 02 2022
Sat Mar 12 2022
  
*/

 



answered Mar 1, 2022 by avibootz

Related questions

1 answer 148 views
1 answer 147 views
1 answer 138 views
1 answer 155 views
1 answer 180 views
1 answer 162 views
...