How to get first and last date of current month in TypeScript

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

...