Moment js get first and last day of current month
There would be another way to do this:
var begin = moment().format("YYYY-MM-01");
var end = moment().format("YYYY-MM-") + moment().daysInMonth();
You can do this without moment.js
A way to do this in native Javascript code :
var date = new Date(), y = date.getFullYear(), m = date.getMonth();
var firstDay = new Date(y, m, 1);
var lastDay = new Date(y, m + 1, 0);
firstDay = moment(firstDay).format(yourFormat);
lastDay = moment(lastDay).format(yourFormat);
In case anyone missed the comments on the original question, you can use built-in methods (works as of Moment 1.7):
const startOfMonth = moment().startOf('month').format('YYYY-MM-DD hh:mm');
const endOfMonth = moment().endOf('month').format('YYYY-MM-DD hh:mm');