Reputation: 12729
How to disable current month date and future date in JavaScript? here is my code https://codesandbox.io/s/condescending-ptolemy-rj3lc
As current month is jan
so I want to disable jan-2020
to all future dates Feb-2020 ...dec-2020
<DatePicker
onChange={onChange}
disabledDate={current => {
console.log(moment().month());
console.log(current.month());
return moment().month() >= current.month();
}}
/>
Upvotes: 0
Views: 462
Reputation: 729
You can use the isSameOrAfter
of moment
<DatePicker
onChange={onChange}
disabledDate={current => current.isSameOrAfter(moment(), 'month')}
/>
Docs: https://momentjs.com/docs/#/query/is-same-or-after/
Upvotes: 2