Try to disable hours for the <TimePicker/>
component by the showTime.disabledHours
prop. But it does not disable the hours. The hours can still be selected.
import React from 'react';
import 'antd/dist/antd.css';
import './index.css';
import { DatePicker } from 'antd';
import type { DatePickerProps } from 'antd/es/date-picker';
const onChange = (
value: DatePickerProps['value'],
dateString: [string, string] | string
) => {
console.log('Selected Time: ', value);
console.log('Formatted Selected Time: ', dateString);
};
const App = () => (
<DatePicker
showTime={{
showHour: true,
showMinute: false,
showSecond: false,
disabledTime: () => ({
disabledHours: () => [
0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23,
],
}),
}}
onChange={onChange}
/>
);
export default App;
stackblitz