-
Notifications
You must be signed in to change notification settings - Fork 642
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
[4.x]: Date field with timezone option loses date on entry save/edit #13233
Comments
Some extra detail: the actual date stored in the db for an entry appears to be correct (what the editor entered), the issue seems to be that when re-displayed in the entry form in the CP the date is incorrectly converted to the system timezone, which means on subsequent saves (where the date field is dirty, e.g. time was edited) the date is decremented by 1 day. |
I came here to submit this same bug except I was having the issue on latest Craft 3 - good to know it's also happening on 4 |
Actually my issue is slightly different in that I have a date only field and the issue still occurs whenever the date field is edited (vs. the time being adjusted) |
Interesting @fernakr thank you. A quick test suggests that In Craft 4 a date-only field seems to work as expected. |
Thanks for reporting! Craft 3.8.12 and 4.4.12 are out with a fix for this. |
Chiming in to say that I had the same confusion regarding template output and the timezone setting - but I didn't know about the getTimezone() method so that'll definitely help me out - thanks Mark! I haven't had a chance to try the fix on Craft 3 yet, but will circle back and confirm when I do. |
Just released Craft 3.8.13 and 4.4.13 with a fix for that element index bug. Now the date/time will use the field’s time zone, and the time zone abbreviation will be shown after it (e.g.
You can pass {{ entry.eventStartDate|date('F d Y', false) }} or if you want to include the time + time zone abbreviation: {{ entry.eventStartDate|date('F d Y, G:i T', false) }} |
Thanks @brandonkelly - that seems to have resolved the issue for me in Craft 3. Also helpful to know about passing |
Addresses concerns in craftcms/cms#13233
What happened?
Description
The day may change if the time is edited and the entry saved, presumably because the system timezone is applied to the
dd/mm/yyyy
part of the datetime (but not the hh:mm part).date-timezone-bug.mov
Steps to reproduce
EDT - New York
18/05/2023 2:00
) with theBST - London
timezone, and save17/05/2023 2:00
On subsequent edits of the entry, the selected date will regress by one day if only the time value is changed. If the field is not edited then the date remains unchanged.
Expected behavior
The field should save the date and time that the editor inputted.
Craft CMS version
4.4.11
PHP version
8
Operating system and version
OS X
Database type and version
MySQL 5.7.34
Image driver and version
No response
Installed plugins and versions
Fresh install.
The text was updated successfully, but these errors were encountered: