Compatibility issues with storing dates in my state using redux-form whilst using the ant design date picker

Viewed 44

The problem is that when i choose date i want it to show as DD-MM-YYYY but i want the date to be saved in my state with the YYYY-MM-DD HH:MM:SS format. How to do this?


export const DatePickerHelper = props => {
  const {
    input,
    datePickerProps,
    formItemStyle,
    formItemLayout = {},
    meta,
    label = null,
    hasFeedback,
    ...extra
  } = props;
  const hasError = meta.touched && meta.invalid;
  const { value, ...filteredInput } = input;


  return (
    <Form.Item
      {...formItemLayout}
      label={label ? label : null}
      validateStatus={hasError ? "error" : "success"}
      hasFeedback={hasFeedback && hasError}
      help={hasError && meta.error}
      style={{ ...formItemStyle }}
    >
      <DatePicker
        value={value ? moment(value) : null}
        {...filteredInput}
        {...extra}
        format="YYYY-MM-DDTHH:mm:ss.SSSZZ"
      />
    </Form.Item>
  );
};





0 Answers
Related