Bootstrap

[React] antd DatePicker 时间日期控件,禁用今日之前/之后的日期

官方文档:https://ant.design/components/date-picker-cn/#API

yarn add moment
import moment from 'moment'
// 限制当天之前的日期不可选
const disabledDate = (current) => {
  return current && current <moment().subtract(1, "days"); //当天之前的不可选,不包括当天
//return current && current < moment().endOf("day");当天之前的不可选,包括当天
}
<Form.Item name='date'>
  <DatePicker allowClear format='YYYY年 MM月 DD日' disabledDate={disabledDate}/>
</Form.Item>

参考链接 : https://blog.csdn.net/weixin_44195250/article/details/109532874

;