I'm using moment.js library to get a date. When I set date to month's end it always returns 30th of each month. But it's not considering that some months has 31 day. How to fix it? Sorry for terrible english.
case 'currentMonth': this.dateTo = moment().endOf('month'); this.dateFrom = moment().startOf('month'); break;
for example: this.dateTo in the next month (july) will return 30.07.19, but there is 31 day in this month
The basic use of moment() will default to the current month. In order to get next month (July) you need to add a month to the date.
var date = moment().add('months', 1).endOf('month');