Set maxDate in the datepicker using Moment

Depending on the year selected in the dropdown, I need to set the date picker minDate and MaxDate. MinDate can only be Jan/01/{selectedYear} and MaxDate should be Dec/01/{selectedYear}

I tried below. But doesn’t seem to work:

MinDate = moment().format(`01/01/${selectedYear}`);
MaxDate = moment().format(`02/01/${selectedYear}`);

Output looks like:

MinDate 01/01/2020 & MaxDate 02/01/2020

9 thoughts on “Set maxDate in the datepicker using Moment”

Leave a Comment