Skip to main content

DateInput and DateTimeInput

Collect a date, or a date and a time, through a MUI X picker.

DateInput stores a plain YYYY-MM-DD string in the local time zone — no time component and no UTC shift. DateTimeInput keeps the time part.

Example​

<DateInput source="delivery_on" disablePast />
<DateTimeInput source="published_at" minDate={new Date()} />

Props​

Both components accept the shared input props, plus the picker constraints below.

NameTypeDefaultDescription
source (required)string—Name of the field in the form record
minDateDate—Earliest selectable date
maxDateDate—Latest selectable date
disableFuturebooleanfalseBlocks every date after today
disablePastbooleanfalseBlocks every date before today
shouldDisableDate(date: Date) => boolean—Blocks individual dates — e.g. weekends
disabledbooleanfalseDisables the input
readOnlybooleanfalseRenders the value without allowing edits

Clearing the picker stores null.

tip

The picker constraints are client-side comfort, not validation. A rule the backend also enforces belongs in validate as well, otherwise a crafted request bypasses it.

Schema mapping​

format: "date" selects DateInput, format: "date-time" selects DateTimeInput, and format: "time" selects TimeInput.

{"name": "delivery_on", "type": "string", "format": "date", "nullable": true}
class Order(models.Model):
placed_at = models.DateTimeField(auto_now_add=True)
delivery_on = models.DateField(null=True, blank=True)

See also​