Antd timePicker keeps showing date when loading the data by using form.setFieldsValue

25 views Asked by At

when I trying to load time string "14:00:00.000+08:00" into the antd timepicker component, the timepicker keeps showing the date with the time. Looks like the date is auto added by dayjs. I only need to load the time in timepicker.

const startDatetime = "14:00:00.000+08:00";
formData.searchStartTime = dayjs((startDatetime).split('.')[0],'HH:mm:ss');

in my form component:

...
useEffect(() => {
    form.setFieldsValue(formData);
  }, [formData]);
...

<Form.Item
                          label={"Search Time Range"}
                          rules={[{ required: true }]}
                        >
                          <Space wrap>
                            <Form.Item name={[field.name, "searchStartTime"]}>
                              <TimePicker placeholder="Start Time"  format="HH:mm:ss" />
                            </Form.Item>
                          </Space>
                        </Form.Item>
0

There are 0 answers