How to get first and last date of current month in Node.js

1 Answer

0 votes
const date = new Date();
const firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
const lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);

console.log(firstDay.toDateString());
console.log(lastDay.toDateString());
  
  
  
  
/*
run:
  
Tue Mar 01 2022
Thu Mar 31 2022
  
*/

 



answered Mar 8, 2022 by avibootz

Related questions

3 answers 246 views
1 answer 126 views
1 answer 180 views
1 answer 157 views
1 answer 164 views
1 answer 152 views
...