Problem
If I select a date in a <DateInput>
, the datetime is in the user's timezone (e.g. 2017-07-01T00:00:00.000+02:00) but when it's sent to the server, it's transformed to UTC and thus ends up as 2017-06-30T22:00:00.000Z, one day behind.
The underlaying back-end is unaware of the user's timezone and cannot shift the dates back so after stripping the time it ends up with wrong date.
What would solve my problem
Any of these options would work fine:
- The datetime is sent with the user's timezone.
- The datetime is sent as naive (=without timezone).
- The date selected by the user is already treated as UTC.
- A date only (2017-07-01) instead of the ISO datetime is sent.
What I tried
- I looked at Admin-on-rest's
DateInput
documentation and haven't found any option to alter the behaviour. - I looked at the related Material-UI's documentation and the only somewhat relevant option appears to be
DateTimeFormat
but despite a couple of tries I got nowhere. - I checked other answers, e.g Material UI Time Picker UTC but cannot figure out how to apply the suggested solution.