Skip to content

[6.x] Fix date-only index fieldtype shifting across timezones#14602

Merged
jasonvarga merged 2 commits into6.xfrom
fix-date-timezone-format
May 4, 2026
Merged

[6.x] Fix date-only index fieldtype shifting across timezones#14602
jasonvarga merged 2 commits into6.xfrom
fix-date-timezone-format

Conversation

@jasonvarga
Copy link
Copy Markdown
Member

Summary

When a date field's format has no time component, Date::preProcessIndexDate() sends the value to the index fieldtype as a Y-m-d string. new Date("2025-12-25") parses that as UTC midnight, and Intl.DateTimeFormat then renders it in the local browser timezone — so anyone west of UTC saw the previous day in listings.

This passes timeZone: 'UTC' to the formatter when format_has_time is false, so the day stays put. The condition hinges on format_has_time only (matching the data shape produced by the backend); the format_has_time=true, time_enabled=false case still has a real ISO moment baked in, so local TZ formatting remains correct there.

Test plan

  • npx vitest run resources/js/tests/components/fieldtypes/DateIndexFieldtype.test.js — added date-only value does not shift across timezones and date-only range does not shift across timezones; updated existing TZ-localization tests to set format_has_time: true so they continue exercising the with-time TZ shift.

🤖 Generated with Claude Code

jasonvarga and others added 2 commits May 4, 2026 18:30
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jasonvarga jasonvarga merged commit 515778b into 6.x May 4, 2026
17 checks passed
@jasonvarga jasonvarga deleted the fix-date-timezone-format branch May 4, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant