How to check if a date is the first day of the month in Node.js

1 Answer

0 votes
function isFirstDayOfMonth(dt = new Date()) {
  	return dt.getDate() === 1;
}


console.log(isFirstDayOfMonth(new Date('2022-05-01')));

console.log(isFirstDayOfMonth(new Date('2022-05-07')));




/*
run:

true
false

*/

 



answered Mar 7, 2022 by avibootz

Related questions

3 answers 246 views
1 answer 148 views
1 answer 145 views
1 answer 145 views
...