diff --git a/packages/core/client/src/schema-component/antd/date-picker/__tests__/mapDatePicker.test.ts b/packages/core/client/src/schema-component/antd/date-picker/__tests__/mapDatePicker.test.ts index 41a8feef50..63c019a10d 100644 --- a/packages/core/client/src/schema-component/antd/date-picker/__tests__/mapDatePicker.test.ts +++ b/packages/core/client/src/schema-component/antd/date-picker/__tests__/mapDatePicker.test.ts @@ -62,7 +62,7 @@ describe('mapDatePicker', () => { }; const result = mapDatePicker()(props); result.onChange(dayjs.utc('2022-02-22 22:22:22')); - expect(props.onChange).toHaveBeenCalledWith('2022-02-22 00:00:00'); + expect(props.onChange).toHaveBeenCalledWith('2022-02-22 22:22:22'); }); it('should call onChange with correct value when showTime is true and gmt is false', () => { @@ -74,7 +74,7 @@ describe('mapDatePicker', () => { const result = mapDatePicker()(props); const m = dayjs('2022-02-22 22:22:22'); result.onChange(m); - expect(props.onChange).toHaveBeenCalledWith('2022-02-22 00:00:00'); + expect(props.onChange).toHaveBeenCalledWith('2022-02-22 22:22:22'); }); it('should call onChange with correct value when showTime is false and gmt is true', () => { @@ -202,7 +202,7 @@ describe('mapDatePicker', () => { }; const result = mapDatePicker()(props); result.onChange(dayjs('2022-02-22 22:22:22')); - expect(props.onChange).toHaveBeenCalledWith('2022-02-22 00:00:00'); + expect(props.onChange).toHaveBeenCalledWith('2022-02-22 22:22:22'); }); it('should call onChange with correct value when picker is year and utc is false', () => { diff --git a/packages/core/client/src/schema-component/antd/date-picker/util.ts b/packages/core/client/src/schema-component/antd/date-picker/util.ts index 4ca70f222a..ebee73bfd8 100644 --- a/packages/core/client/src/schema-component/antd/date-picker/util.ts +++ b/packages/core/client/src/schema-component/antd/date-picker/util.ts @@ -100,6 +100,9 @@ const handleChangeOnForm = (value, dateOnly, utc, picker, showTime, gmt) => { const formattedDate = dayjs(value).format(format); return dayjs(formattedDate).toISOString(); } + if (showTime) { + return dayjs(value).format(format); + } return dayjs(value).startOf(picker).format(format); };