Skip to content

Fix timezone shift in search when using date-only input#841

Open
NativoDigital wants to merge 1 commit intoOctopoos:masterfrom
NativoDigital:fix-timezone-calendar
Open

Fix timezone shift in search when using date-only input#841
NativoDigital wants to merge 1 commit intoOctopoos:masterfrom
NativoDigital:fix-timezone-calendar

Conversation

@NativoDigital
Copy link
Copy Markdown
Contributor

This pull request addresses the issue described in Issue #679, where the calendar field in search mode returns results from the previous day when Joomla is configured with a timezone other than UTC.

Bug: calendar search field returns previous day when Joomla timezone ≠ UTC

When using the calendar field in search mode (onCCK_FieldPrepareSearch), and Joomla is configured with a timezone like GMT+2, searching for a specific date (e.g. 2025-05-27) returns items from the previous day.

This is due to the fact that date-only inputs (e.g. 2025-05-27) are interpreted as midnight in the local timezone (2025-05-27 00:00:00), and then converted to UTC (2025-05-26 22:00:00), which shifts the intended search range.

Solution

The fix adds a check to detect whether the input date string includes a time component. If not, it appends 12:00:00 before the conversion to UTC. This avoids the unintended shift to the previous day.

Added in onCCK_FieldPrepareSearch():

$hasTime = strpos($value, ':') !== false;

if (!$hasTime) {
    $value .= ' 12:00:00'; // Prevent timezone shift to previous day
}

Scope

  • This fix only affects search forms.
  • It does not affect how values are stored or displayed elsewhere.
  • It is compatible with modify settings (like -1 day), and has been tested across different Joomla timezone settings.

Thanks for maintaining Seblod. I hope this small fix will help others experiencing this issue.

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.

2 participants