Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
how to disable future time in material-ui KeyboardDateTimePicker in reactjs

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!