-1

enter image description here

Below is my code where I need to display calendar with month and year and when user selects month and year it should display last day of that month with year. I am able to get the date as 01 June 2022 using below code, where as I need date as 30 June 2022

1 Answers1

0

Quickest way is using a library like moment (depreacated) or dayjs. Take the date you get from datepicker, and use it with the library to get the end date of the month-year.

Change the dateInputFormat to YYYY-MM-DDDD in the bsConfig.

Inside your getDate() function process the datePicker date to get proper format.

Example code:

const date = '2022-06-01';
console.log('Print date: ', moment(date).endOf('month').format('DD MM YYYY'));

Result: enter image description here

Nehal
  • 13,130
  • 4
  • 43
  • 59