I'm trying to get start and end of the current month but for march it is giving me the start date as 2020-02-29T00:00:00.000Z
Using momentjs
var firstDay = new moment().startOf('month').utcOffset(0);
firstDay.set({hour:0,minute:0,second:0,millisecond:0});
var lastDay = new moment().endOf('month').utcOffset(0);
lastDay.set({hour:23,minute:59,second:59,millisecond:0})
Using Date()
var date = new Date(),
y = date.getFullYear(),
m = date.getMonth();
var firstDay = new Date(y, m, 1);
var lastDay = new Date(y, m + 1, 1);
How to solve this?