cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x] Allow different timezone from app timezone for displaying date+time in CP and Antlers

Open florianbrinkmann opened this issue 1 year ago • 7 comments

Laravel encourages to not change the default UTC timezone in the config (https://laravel.com/docs/11.x/eloquent-mutators#date-casting-and-timezones), to prevent issues when comparing dates etc.

That said, I thought about how we could have both: the UTC timezone for all stored date/time values, but the values in the CP being displayed like in another timezone, for example Europe/Berlin, so if an editor in Germany tries to publish an entry immediately which has date+time enabled, it gets published right away and not when the UTC time is at the current point (so in one or two hours, depending on Daylight saving time)

I guess I did not find all places where that check and conversion should happen, so if you know of other places, please let me know :)

In general it should not change anything for existing and new installs, except the config value is set.

florianbrinkmann avatar May 22 '24 14:05 florianbrinkmann

This could be great. I wonder if the client timezone should be a per site config option in sites.yaml so this could work for multisite as well.

robdekort avatar May 22 '24 14:05 robdekort

I like the idea! Will check that out

florianbrinkmann avatar May 22 '24 14:05 florianbrinkmann

Also a user account timezone setting/override would be really useful, for when you have CP users in different timezones.

jacksleight avatar May 22 '24 15:05 jacksleight

I think there should be an app config like you've done, and then a user preference that overrides it.

I wouldn't go as far as making different ones per-site.

jasonvarga avatar May 22 '24 15:05 jasonvarga

This is a conflicting effort with https://github.com/statamic/cms/pull/8636. We'll need to figure out the approach and consolidate them.

jasonvarga avatar May 22 '24 15:05 jasonvarga

I wouldn't go as far as making different ones per-site.

Fair enough. We can probably already do that with a custom site attribute and some Antlers logic.

robdekort avatar May 22 '24 15:05 robdekort

I think there should be an app config like you've done, and then a user preference that overrides it.

User preferences sounds good, but that preference would have to be limited to the CP part, so not in the src/Data/AbstractAugmented.php (not sure if that’s the best place), where it changes the values for displaying values of date fields in Antlers.

florianbrinkmann avatar May 22 '24 16:05 florianbrinkmann

I accidentally deleted my fork 🫠 I just re-created it with the branch, is it possible to reopen here or do I need to create a new PR? /cc @jasonvarga

florianbrinkmann avatar Jan 22 '25 14:01 florianbrinkmann

You might need to create a new pull request.

duncanmcclean avatar Jan 22 '25 14:01 duncanmcclean

Okay, thanks, created a new one https://github.com/statamic/cms/pull/11388

florianbrinkmann avatar Jan 24 '25 08:01 florianbrinkmann