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
Asked
Active
Viewed 267 times
-1
-
1Please not post code snippets as a screenshot. – Jarek Jul 15 '22 at 15:51
1 Answers
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'));

Nehal
- 13,130
- 4
- 43
- 59
-
How can I display only current year and month from march to till current month in bsDatepicker? – tripti tiwari Sep 27 '22 at 04:56