I want to remove minutes value that is not divisible by 15 in Material Ui TimePicker component.
I am trying this approach but this is not working
const shouldDisableTime = (timeValue) => {
const minutes = timeValue?.$m;
return minutes !== 0 && minutes !== 15 && minutes !== 30 && minutes !== 45;
};
<LocalizationProvider dateAdapter={AdapterDayjs}>
<TimePicker
value={time}
onChange={(newValue) => setTime(newValue)}
minutesStep={15}
shouldDisableTime={shouldDisableTime}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
2
Answers
Instead of disabling time with
shouldDisableTime()
function you can useminutesStep={15}
prop and for hiding not necessary minutes you can useskipDisabled
boolean property with setting value to true.Full
<TimePicker />
component API can be found here.See example screenshot bellow.
Yes, it’s possible. You need to pass the timeSteps prop to
If you have to change hours and minues then use it like that way