[Vuejs]-Element UI – DateTimePicker how to disable past dates vue.js

1👍

You can achieve this by adding a :disabled-date attribute in the <el-date-picker> element and pass the boolean value to this attribute based on the calculation.

<el-date-picker :disabled-date="disabledDate" ...

In Script:

const disabledDate = (time: Date) => {
  const date = new Date();
  const previousDate = date.setDate(date.getDate() - 1);
  return time.getTime() < previousDate; 
}

Leave a comment