how to automatically get date in specific format from DatePicker?

Viewed 100

I'm using the component DatePicker from antd.

I have currently a Form from antd, in which there's a Form.Item, in which I put the DatePicker.

I want the Form.Item to be given the date in a specific format, lets say YYYY-MM-DD, is there a way to do that?

by giving it the prop format I can choose how it will look like in the UI but I'm trying to make it send back the value by the same format.

I've tried giving it a dateFormat prop with the function

function dateFormat(date) {
  return moment(date).format("YYYY/MM/DD");
}

but it doesn't work.

is there a way to do this manipulating the data in the onChange function?

1 Answers

so apparently there's no way to do it in the props, I've checked and so has @MoaazBhnas.

If anyone somehow finds a way, I'll be looking forward to hear!

Related