material ui datepicker format code example

Example 1: material ui datepicke

import React, { Fragment, useState } from "react";
import { TextField } from "@material-ui/core";
import { MobileDatePicker, DesktopDatePicker, DatePicker } from "@material-ui/pickers";

function DatePickersVariants(props) {
  const [selectedDate, handleDateChange] = useState(new Date());

  return (
    <Fragment>
      <MobileDatePicker
        clearable
        label="For mobile"
        inputFormat="MM/dd/yyyy"
        toolbarPlaceholder="Enter Date"
        value={selectedDate}
        onChange={date => handleDateChange(date)}
        renderInput={props => <TextField {...props} />}
      />

      <DesktopDatePicker
        autoOk
        label="For desktop"
        minDate={new Date("2017-01-01")}
        value={selectedDate}
        onChange={date => handleDateChange(date)}
        renderInput={props => <TextField {...props} />}
      />

      <DatePicker
        disableFuture
        label="Responsive"
        openTo="year"
        views={["year", "month", "date"]}
        value={selectedDate}
        onChange={date => handleDateChange(date)}
        renderInput={props => <TextField {...props} />}
      />
    </Fragment>
  );
}

export default DatePickersVariants;

Example 2: date range MUI

$ npm install material-ui-datetime-range-picker

Example 3: date picker material ui

hello there