[6.x] Add configurable timezone for date fields in the Control Panel#14554
Open
duncanmcclean wants to merge 13 commits into6.xfrom
Open
[6.x] Add configurable timezone for date fields in the Control Panel#14554duncanmcclean wants to merge 13 commits into6.xfrom
duncanmcclean wants to merge 13 commits into6.xfrom
Conversation
Add a per-field `timezone` config option and a site-wide `statamic.cp.date_timezone` config so dates can be pinned to a specific timezone instead of always using the browser's local timezone. Resolution order: field config > cp.date_timezone > browser local. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update the frontend to treat 'auto' as the signal for browser-local timezone, matching the refactored resolvedTimezone() which always returns a string. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The DateIndexFieldtype now receives the resolved timezone and uses it with Intl.DateTimeFormat so listing views display dates in the configured timezone. The timezone config field's placeholder now shows the CP default timezone instead of "Auto" when one has been configured. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The dictionary fieldtype may return an array value even with max_items set to 1. Handle both array and string cases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The tooltip was always using timeStyle: 'long' which showed a misleading time even for date-only fields. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a static presets getter to DateFormatter instead of duplicating the preset objects in the index fieldtype component. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The replicator preview was always using browser-local timezone formatting. Now it respects the field's configured timezone via the displayTimezone computed property. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This reverts commit dcad5ae.
The instance #presets field was duplicating the static presets getter. Now #normalizeOptions references DateFormatter.presets directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a timezone option to the Date fieldtype, allowing dates in the Control Panel to be displayed and entered in a specific timezone rather than always using the browser's local timezone.
This is useful when you want all users to use the same timezone, wherever they are physically located.
You can either configure a default timezone for all Date fields across your site, or on a per-field basis:
Site-wide default
This PR adds a
default_timezoneconfig option toconfig/statamic/cp.php.It defaults to
auto(browser's timezone) but can be set to any IANA timezone (e.g.America/New_York) to pin all date fields to that timezone by default:Per-field override
Individual date fields can override the site-wide default via a new "Timezone" config option in the field's settings:
Closes statamic/ideas#1453
Closes statamic/ideas#1441