Timezones for users

I have an issue where users may be in different timezones when filling a date-field in the Panel. The data the panel writes into the page’s file should always use “Europe/Berlin”.

I have set date_default_timezone_set(‘Europe/Berlin’); to let Kirby know the server-side timezone to be used, how can I let the Panel know to translate the user’s timezone into the server’s timezone? Can user’s have a timezone-property the Panel respects?

Example:

User is in London and selects 31. December 2025, 11:15 pm. The Panel should save 1. January 2025, 00:15 am.

I need this to be handled by PHP or at least Kirby. Coding this manually for every single timezone is utterly unrealistic – and afaik PHP knows how to do it.


TL;DR:

Is there a way to make Kirby respect a user’s timezone and translate it into the server’s timezone when saving from the Panel?

As far I recall, Kirby tries to strip timezone from the date and basically stores it without any timezone - as when timezones were included this ended up in a lot of problems. If your events depend on certain (different) timezones, I would suggest to add another field to store the timezone and then in your templates casting the stored date and time to that timezone.

I think I might have made a mistake when asking. The goal is to store the publication date of a page — always in the same timezone. The user should be able to define the date and time of publication in their local timezone, and that gets translated into the date and time that moment is for the server. If the user is in a different timezone than the server, the panel should perform this translation when saving and retrieving this data.

I think that would be a feature request for feedback.getkirby.com - currently the field is timezone-agnostic: if you put in 12 Jan 2025 20:15 it will be 2 Jan 2025 20:15 in the content and template, no matter where the editor was who put it in. That was the best result for events where before some editors had really troubles when their browsers etc. unknowingly had a different timezone set. It seemed better to store the date time timezone agnostic and have developers add in explicitly a timezone when needed.

I can see that for a publication date the taking the local timezone of the editor into the equation could make sense, but it’s nothing the field right now can do. For now, a help text with something like “Please enter the date and time according to UTC” or something like this could be a solution.

1 Like