Incremental Steps

By default, the DateInput increments or decrements each part of its date values by one step.

To change the default setup, use the steps property.

The available options are:

  • year: Number—Controls the incremental step of the year value.
  • month: Number—Controls the incremental step of the month value.
  • day: Number—Controls the incremental step of the day value.
  • hour: Number—Controls the incremental step of the hour value.
  • minute: Number—Controls the incremental step of the minute value.
  • second: Number—Controls the incremental step of the second value.
class App extends React.Component {
    state = { value: new Date(2017, 2, 10, 13, 30, 0) };
    steps = { year: 10, day: 5, hour: 2, minute: 15 };

    render() {
        return (
            <div className="example-wrapper">
                <div className="col-xs-12 col-sm-6 example-col">
                    <p>Incremental steps:</p>
                    {
                        Object.keys(this.steps).map((step, _) =>
                            <p key={step}>{step} - {this.steps[step]}</p>
                        )
                    }
                    <DateInput
                        format="MM/dd/yyyy hh:mm a"
                        steps={this.steps}
                        value={this.state.value}
                        onChange={this.changeDate}
                    />
                </div>
            </div>
        );
    }

    changeDate = (event) => {
        this.setState({ value: event.value });
    }
}

ReactDOM.render(
    <App />,
    document.querySelector('my-app')
);

In this article

 /