0

I am using input textfield in React with type date which stores date in format 2021-07-22T00:00:00.000Z in MongoDB. I want the data in the edit form so that the date stored comes in edit form and we can again change it from the date picker.

The code for the input field is

<TextField name="purchaseDate" type="date" required variant="outlined" fullWidth value={bookData.purchaseDate} onChange={(e) => setBookData({ ...bookData, purchaseDate : e.target.value })} />
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Yogeshwari
  • 1
  • 1
  • 3
  • You haven't set the value property of the `TextField` to show the value from DB. – SelvaS Jul 29 '21 at 17:11
  • Seems `TextFiled`'s type is kind of ``. How the date is changed for now? – jacobkim Jul 30 '21 at 08:10
  • TextField is like input tag in material ui so it also allows which type of input we want and here I want input of date type which on clicking shows calendar to choose date. – Yogeshwari Jul 30 '21 at 17:21
  • Does [Change locale in react-datepicker](https://stackoverflow.com/questions/54399084/change-locale-in-react-datepicker) offer anything useful? – Andrew Morton Aug 20 '21 at 19:11

0 Answers0