core114
core114

Reputation: 5335

How to disable ant design time picker paste time

Im using ant design time picker for my react application, i have some conflict on the time pricker, i want to know how to disable past time before the today current time.

This is my code

   getDisabledTime = () => {

        var hours = [];
        for(var i =0; i < moment().hour(); i++){
            hours.push(i);
        }
        return hours;

    }


 <TimePicker onChange={onChange} disabledTimes={this.getDisabledTimes()}/>

Upvotes: 0

Views: 2067

Answers (1)

maazadeeb
maazadeeb

Reputation: 6112

The prop name is disabledHours and it is a function.

function getDisabledHours() {
  var hours = [];
  for (let i = 0; i < moment().hour(); i++) {
    hours.push(i);
  }
  return hours;
}


<TimePicker disabledHours={getDisabledHours} />

Working codesandbox.

Upvotes: 1

Related Questions