Cant set min and max date of datetime picker for ionic


In my ion-datetime I have dates to select. These dates are the dates provided from a function that finds the next available dates for delivery.

Here we have the function that gets the dates then set our result:

let result = getValidDates()
let temp = []
result.forEach(res => {
this.min = result[0].toLocaleDateString()
this.max = result.slice(-1)[0].toLocaleDateString()
this.pickupdates = result

Then we have our component with the dayValues property which is the result from the above function:

  [dayValues] = "pickupdates"
  [min] = "min"
  [max] = "max"

This then gives us the proper selectable dates. But those very same dates are the same dates that can be selected in the next month.
Ive tried tried to limit this by adding the min and max properties, but this then breaks and bring up the error:
"Cannot destructure property ‘month’ of ‘parseDate(…)’ as it is undefined."
"TypeError: Cannot read properties of undefined (reading ‘month’)"

In this case min and max would be:

min = "26/04/2022"
max = "02/05/2022"

but still brings up that error


the reason is min date max date should be yyyy/mm/dd or mm/dd/yyyy to be brief min="04/26/2022" and max="05/02/2022"

Answered By – sai kiran

Answer Checked By – Robin (AngularFixing Admin)

Leave a Reply

Your email address will not be published.