Search code examples
react-admin

DateInput : ISO formatting with timezone


Currently, the DateInput sends value as "yyyy-mm-dd"

My backend API uses a stricter approach where you need to specify the timezone (i.e a full .toISOString() instead of only the 10 first chars)

Is it possible to change how DateInput serializes its value ?

From my understanding, as DateInput relies on HTML input type="date", this can not be easily changed as yyyy-mm-dd is hardcoded in the HTML spec.

Maybe I can provide an IsoDateInput but I do not know how to do this ...


Solution

  • If you need to convert a data format, you can pass your parse() / format() functions to DateInput: https://marmelab.com/react-admin/Inputs.html#transforming-input-value-tofrom-record