'React html date picker change date label
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?
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
Solution 1:[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>;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Harsh2720 |

