Reputation: 43
Show only last 30 days from today in npm react-date-picker dynamically in react. Future dates from tomorrow should be disabled.
import DatePicker from "react-date-picker";
<DatePicker maxDate={new Date()} />
Upvotes: 1
Views: 2401
Reputation: 480
maxDate={new Date().setDate(new Date().getDate() + 90)}
Future date disable in react js. Here from today 90 days will be available for selecting
Upvotes: 1
Reputation: 391
you can use moment() and especially the function subtract() like in the exemple:
<DatePicker maxDate={new Date()}
minDate={moment(new Date()).subtract(30, 'days')} />
Upvotes: 0
Reputation: 8503
What exactly is the question? You can create a date 30 days from now in JavaScript as follows:
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 30);
Upvotes: 0