To begin, I retrieve the date for the first day of the month:
var currentDate = new Date();
var beginningOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
Next, I convert this date to ISO format:
beginningOfMonth = beginningOfMonth.toISOString();
I was puzzled by the fact that 2019-05-31
was displayed as the first day rather than 2019-06-01
. Can you explain why?