I found this code can be used to find the first date and the last date of a current month.
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
Today is 11/1/2018
I used this piece of code for a calendar I am developing for one of my projects. Even though it should return first day of the month as 2018-01-01T18:30:00.000Z
it returns the first day as 2017-12-31T18:30:00.000Z
and the last date as 2018-01-30T18:30:00.000Z
.
But there are 31 days in January. So what is wrong with this code?
I found the code from a stackoverflow question