this has been answered here however maybe something has changed as that no longer works.
function firstAndLast() {
const startDate = new Date(2020, 8, 1);
const endDate = new Date(2020, startDate.getMonth() + 1, 0)
console.log('startDate', startDate) // <-- 2020-08-31T22:00:00.000Z
console.log('endDate', endDate) // <-- 2020-09-29T22:00:00.000Z
}
firstAndLast();
as the docs say the parameters are new Date(YYYY, MM, DD, hh, mm, ss, ms)
I am entering the year 2020
the month august
(note this is node not browser) and day 1
the first of the month. What is going on here?