How to check if a date is the first day of the month in JavaScript

1 Answer

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


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

console.log(isFirstDayOfMonth(new Date('2022-03-04')));




/*
run:

true
false

*/

 



answered Mar 7, 2022 by avibootz

Related questions

...