Date field stores wrong date (+ 1 day)

Hi, I don’t know, if it is an bug, but I hope its my fault an you can help me:

For one of my clients (musician) I made a gigs calendar. It’s a simple a structure field with a date field and a time field as sub-fields.
When he creates a new gig and saves the changes everything looks fine, but when he reloads the panel, the date of the gig is now plus one day (example: he saves 2024-12-31 and after reloading the value changes to 2025-01-01)
When I observe the changes in the txt-content-file, the wrong date ist saved with the initial saving.

can you help me? is it a timezone-problem? in the reference I don’t find an entry that deals with this topic…

thanks a lot,
best regards,
Matthias

Which Kirby version are you using? What timezone does the server use?

the Kirby-Version is 4.5
and how can I check the timezone of the server?
when I type “date” in SSH-Shell I get the correct date and time (CET)…

I thought this had long been fixed, there is a very long thread on Github(Date Field does not store the picked date properly · Issue #2416 · getkirby/kirby · GitHub), referring to older versions of Kirby.

I’d do as suggested in that thread and try to set the default timezone in index.php. Or use the date with time enabled.

i also found the thread you mentioned, but perhaps it’s a new bug?
i also found this issue from summer of this year, perhaps it’s the same bug…

I tried to set the default timezone in index.php like mentioned in the old thread but I doesn’t help.
Today early in the morning (6:00 am) I tested again, and the bug has gone! Crazy! could be a hint that it has to do with a timezone issue.
I enabled time for the date field now and check later if it works as expected…

Okay, it’s getting more and more crazy!!!
Now I changed the blueprint to a date field with time enabled and removed the date format field property. The behavior mentioned in my first post seems to be gone, but now the following happens:
when I enter a date at the end of a year (for example 2024-12-31) everything looks good in the panel, and also the content file is correct, but in the front-end the year is PLUS ONE YEAR (2026)!!!
I use the toDate() method with intl date-handler…

really crazy!!!

Okay, i tested a little bit more with the actual starter kit and I think I found a bug in the toDate()-method in Combination with intl-datehandler.
It is reproducible:

  1. build a page with structure field and a date field inside
  2. create an entry with a date near the end of a year
  3. output the structure field entries in your template with
<?php $dates = $page->datesstructure()->toStructure();
foreach ($dates as $date): ?>
<span><?= $date->datefield()->toDate('dd.MM.Y') ?></span>
<?php endforeach ?>

if the date-entry is for example 2024-12-31 the output will be 31.12.2025

can anyone else confirm this?

Correct format would be toDate('dd.MM.yyyy')

oh, I’m so stupid :face_with_peeking_eye: this fixes everything… :melting_face: