0

I have an array with all months and the number of the month, like this :

  months = [
    { name: 'JANUARY', id: 0 },
    { name: 'FEBRUARY', id: 1 },
    { name: 'MARCH', id: 2 }
   ......
]
Rakid Naomi
  • 61
  • 1
  • 10
  • https://stackoverflow.com/a/26131085/7562674 it already have implementation. getMonthDateRange(year, month) => current year : moment().year(); and for month will be selected month id. – Himanshu Sharma Jun 12 '20 at 10:54

2 Answers2

0
startAndEndOfSelectedMonth() {
    let year = new Date().getFullYear();
    let startDate = moment([year, this.month - 1]);

    let endDate = moment(startDate).endOf('month');

    return { start: startDate, end: endDate };
}
sreejithsdev
  • 1,202
  • 12
  • 26
0

I think this similar post (sharing the link below) will help you for achieving your goal. Concept remains the same.

Link Get first and last date of current month with JavaScript or jQuery

Wahab Shah
  • 2,066
  • 1
  • 14
  • 19