SEBLOD icon indicating copy to clipboard operation
SEBLOD copied to clipboard

Fix timezone shift in search when using date-only input

Open NativoDigital opened this issue 11 months ago • 0 comments

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.

NativoDigital avatar May 27 '25 19:05 NativoDigital