Note: Issue and my MRs are created with the help of AI, reviewed and checked by me.

Problem/Motivation

Smart Date replaces core's Views date filter (smart_date_views_plugins_filter_alter()). Its Date::getMinAndMax() parses the value with new DateTimePlus($value, $site_timezone). When the value carries its own offset (2026-10-12T15:23:23Z, @1791818603, …+05:00), PHP keeps that offset. The code then reads year, month, day, hour, minute and second from the object and rebuilds the timestamp with createFromArray(…, $site_timezone). So the wall-clock time of the input's zone is reinterpreted as site time, and the filter value moves by the difference of the two offsets.

Core's Date filter (strtotime()) handles the same input correctly. Smart Date 4.0.x did too, at granularity "second"; the shift came with the getMinAndMax() refactor in #3410547.

This hits every exposed or contextual date filter that receives machine input: feeds and APIs with a changed_since / from parameter in UTC or as a unix timestamp. For > the filter returns up to one or two hours of extra items. For < it drops items.

Steps to reproduce

  1. Site timezone Europe/Vienna, Smart Date 4.2.x or 4.3.x enabled.
  2. A view on nodes with an exposed changed filter, operator &gt;=, granularity "second".
  3. Pass 2026-10-12T15:23:23Z, the same moment as @1791818603 or 2026-10-12T17:23:23+02:00.
Input core strtotime() Smart Date Difference
2026-10-12T15:23:23Z 1791818603 1791811403 −7200 s
@1791818603 1791818603 1791811403 −7200 s
2026-10-12T17:23:23+02:00 1791818603 1791818603 0
2026-10-12 17:23:23 1791818603 1791818603 0
2026-01-12T15:23:23Z 1768231403 1768227803 −3600 s

Proposed resolution

In getMinAndMax(), convert the parsed dates to the site timezone before the components are read:

Remaining tasks

  • MR against 4.3.x with the fix and the test.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork smart_date-3630565

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fago created an issue. See original summary.

fago’s picture

Issue summary: View changes
fago’s picture

Issue summary: View changes

fago’s picture

Status: Active » Needs review

created MR with fix and test-coverage

fago’s picture

there are some phpstan fails, but those seem to be not in the files I touched.

mandclu made their first commit to this issue’s fork.

mandclu’s picture

I merged in the changes already committed in #3615276: Fix remaining entity-storage dependency-injection PHPStan errors and now all the tests pass. This looks safe to merge, but I want to give it one more pass, hopefully later today.