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

1 answer 139 views
1 answer 194 views
3 answers 263 views
1 answer 169 views
1 answer 176 views
1 answer 162 views
...