Date provided in Date Field is inconsistant with it's response form provided via Rest API. Propable cause is the timezone difference.
I provide data via Data Field. The provided date is like 24.05.2022, 10:00 AM. The rest response should be exactly the same.
The date in response is however : 24.05.2022, 8:00 AM - two hours prior to what I've provided.
Check the timezone of Admin frontend and adjust the timezone stamp accordingly, or build functionality to adjust timezone of API response via admin. If I understand correctly, at this point the response date is set via server time, which may differ from the timezone of the browser in whicz admin is working.
Current Payload version, Latest Chrome browser, UTC+1 timezone. Payload hostedn on Heroku, without the ability to granular control of the timezone of server.
Since we deterimined there isn't anything in Payload to fix I'm moving this to a discussion for others to see.
Thanks for reporting this @quornik. We're considering what the configuration settings will be for timezone and what effects it will have for the admin UI and APIs to solve the issue. We'll update again when we have a plan or fix ready.
Thanks @DanRibbens.
You should also consider if I haven't rushed to quickly to call it a bug. Maybe it works properly and what it actually needs is just slightly updated documentation to the field. A warning of some kind that one should always localize the response.
If you think about it, the best practice is to adjust the timezone always on frontend, after the dateObject has been received and befere it is displayed, because the user's context should determine the way date is interpreted & displayed.
The scenario in which I had a problem with the way it works now, was this particular situation that I did not localize the response date before displaying. In every other situation it works fine.
If you think about it, the best practice is to adjust the timezone always on frontend, after the dateObject has been received and befere it is displayed, because the user's context should determine the way date is interpreted & displayed.
Exactly, @quornik. This isn't really a bug per se, rather, it's a potentially useful admin UX enhancement.
We're thinking through how to make this happen as Dan said and will report back here once we have more!
Here's a use case that doesn't fit the current setup too well - I'm adding events using payload, however the events I'm adding take place in a different timezone to where I am currently.
It seems payload converts my local time to UTC and stores that - it means I have to do some calculating to input the time I want as it would be in my current timezone.
I think a possible solution would be to have the ability to select the timezone of the time you are entering, though I'm not sure if react-datepicker
supports this.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.