How to get the monday date of the current week in Node.js

1 Answer

0 votes
function getMondayDateOfCurrentWeek() {
  	const today = new Date();
  	const first = today.getDate() - today.getDay() + 1;

  	const monday = new Date(today.setDate(first));
  
  	return monday;
}


console.log(getMondayDateOfCurrentWeek().toDateString());

 
  
   
  
/*
run:
  
"Mon Mar 14 2022"
  
*/

 



answered Mar 31, 2022 by avibootz

Related questions

1 answer 181 views
1 answer 127 views
1 answer 185 views
1 answer 125 views
1 answer 131 views
131 views asked Apr 2, 2022 by avibootz
1 answer 181 views
...