RangePicker 组件
<RangePicker
onChange={onSearch}
placeholder={[
formatMessage({ id: 'page.Business.StartTime' }),
formatMessage({ id: 'page.Business.EndTime' }),
]}
format="YYYY-MM-DD HH:mm"
disabledDate={disabledDate}
disabledTime={disabledDateTime}
showTime={{ format: 'HH:mm' }}
/>
当天往后的时间禁用
function disabledDate(current: any) {
let result = false;
if (current > moment().add(0, 'days')) {
result = true;
}
return result;
}
当天现在时刻往后时分禁止(秒类似 可以自己添加)
function disabledDateTime(dates: any) {
const hours = moment().hours();
const minutes = moment().minutes();
const seconds = moment().seconds();
if (dates && moment(dates).date() === moment().date()) {
return {
disabledHours: () => range(hours + 1, 24),
disabledMinutes: () => range(minutes + 1, 60),
disabledSeconds: () => range(seconds + 1, 60),
};
}
return {
disabledHours: () => [],
disabledMinutes: () => [],
disabledSeconds: () => [],
};
}
现在是2021/9/24 22:42