New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date field converting to UTC incorrectly #8954
Comments
Confirmed on latest release (v3.4.0) and current master as of commit: 6202424 Steps to reproduce:
Expected result is date remains on 2020-12-03, just dates should not be converted, only datetime. |
Hello @derrickmehaffy and @codfish, I have the same issue after upgrading from strapi v3.3.x to the latest v3.4.0 using PostgresDB. I can also save an entry even if the required fields are left empty. |
Unrelated and that action is expected if you have draft and publish enabled, you can save without the required but you can't publish. |
@derrickmehaffy The event is "published" and the date value is saved in the Database and shows up in the API request and everything but does not show up in the admin after saved. I will submit another issue because a required field should not be left empty, it was working just fine before the upgrade to v3.4.0. I wish I could fix it myself and send a pull request, thank you for everything @strapi team 🚀🚀🚀 |
Yeah please open up a new issue for that, drafts don't need the required fields but published items need to be. |
@derrickmehaffy @EAdeveloper So I could be wrong but I'm pretty sure the values are set, NOT empty. But it's just not being displayed in the component. So that bug is just that the component isn't displaying the value properly, i don't think it's a validation issue (cause the values are set under the hood). This is separate from the conversion bug though I suppose, so if you wanted to open a ticket anyway, that would probably be best. |
You are correct, they were, and that issue was fixed in v3.4.1 Date field being converted is still a bug. |
Still running into this bug. Is there any plans to fix this in the next release? If not, where would be a good point to start in order to fix this myself? |
I'm on 3.6.3 and confirm the issue. Every time I create an entry with Date field using API call (using ISO format) , the date persisted is moved even by 2 days earlier. This happens only for Date fields. Does not happen on DateTime fields. |
The conversion could use the number constructor of Date as a workaround. Or add an extra blank space after the ISO date |
The source of the issue us much harder to deal with in the v3, we are looking to fix this in the v4. |
Hello, In v4, Date fields have the same problem : if I put 2022-01-05, when I save, it shows then 2022-01-04... Maybe for date only, the date fields should not use the locale timezone and send it with Z timezone, so '2022-01-05T00:00:00Z' to keep the correct date ? |
duplicate: #11509 |
Bug report
Describe the bug
Note: I'm in NYC, so it's currently UTC-05:00.
Two issues I'm seeing here:
Date
's will assume a date string you provide is UTC and convert it to local for you:When using a date time field it works correctly (whatever time I put in is treated like local time, and on submit its sent as the correct UTC to the api).
Steps to reproduce the behavior
If you're west of GMT like I am, you'll see the date get decremented by a day. You can view the network requests in dev console to see the dates being sent and received.
My scenario:
book
content typerelease_date
field of typedate
Expected behavior
I'll start by saying the ultimate goal and my expectation is that if I save a date time, date, or time in the CMS and refresh the page, I would expect it to show me exactly what I input, regardless of how the data is stored. Currently, that's not what's happening for me.
Screenshots
https://share.getcloudapp.com/rRu0O0w5
System
Additional context
I've worked on CMS's in the past and we've had to solve this issue one way or another depending on the scenario. One possible solution would be to tack on a timestamp WITHOUT the timezone designator. Date API will treat that as local time and won't try to convert it.
This may be irrelevant for this bug, however it's worth noting for anyone that stumbles on this with similar scenarios: even if you fix the issue it won't actually solve my use case, cause while it will say 12/15/2020 for NY timezone which is expected, the (proper) conversion will make it the 24th in California for instance, which is not really what I'm looking for. So in my case I can probably opt for either:
2020-12-25
and add theT00:00:00
on the frontend when formatting the date to prevent any utc to local conversions.The text was updated successfully, but these errors were encountered: