-1

enter image description here

When I capture the selected date to a variable it displays like this "YYYY-MM-DD" But in the HTML date picker "MM/DD/YYYY"

All I want is to change that label to "YYYY-MM-DD" from "MM/DD/YYYY". I hope there should be a way to do this in JS with React instead of using another date picker library. How do I do this in React?

Codesandbox

Updated HTML date picker (input type date) display date label like this "MM/DD/YYYY" I do want to change it to display like "YYYY-MM-DD" in the input element

margherita pizza
  • 6,623
  • 23
  • 84
  • 152

1 Answers1

-1
<div className="flex flex-col items-start max-w-sm">
  <label>A single "datetime" input</label>
  <DatePicker defaultValue={new Date()} includeTime />
  <br />

  <label>Paired picker and dropdown</label>
  <div className="flex space-x-2 w-full">
    <DatePicker
      defaultValue={new Date()}
      className="w-3/5"
    />
    <DropdownList
      data={getTimeList()}
      textField="label"
      className="w-2/5 mt-0"
    />
  </div>
  <br />
  <label>Paired picker and experimental time input</label>
  <div className="flex space-x-2 w-full">
    <DatePicker
      defaultValue={new Date()}
      className="w-3/5"
    />
    <TimeInput
      defaultValue={new Date()}
      className="w-2/5 mt-0"
      use12HourClock
    />
  </div>
</div>;
Harsh2720
  • 1
  • 2