I'm using Material UI KeyboardDateTimePicker and by using disabledFuture I was able to disable future date but I want to disable future time as well. any solution would be appreciated
import { KeyboardDateTimePicker } from "@material-ui/pickers";
<KeyboardDateTimePicker
color="primary"
disableFuture
format="yyyy-MM-dd hh:mm a"
label={intl.formatMessage({ id: "end" })}
margin="normal"
onChange={(x) => onChange({ from, to: x?.toJSDate() ?? null })}
value={to}
variant="inline"
maxDate={new Date()}
/>
Note - i don't want to update library
You can validate the value yourself by passing down an error prop to the underlying Textfield component, if the dateTime is in the future.
<KeyboardDateTimePicker
value={to}
error={dateTimeIsInFuture(to)}
You can then add a custom error message using the helperText prop: react material - ui text field validation : set custom error messages.