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
- Site timezone
Europe/Vienna, Smart Date 4.2.x or 4.3.x enabled. - A view on nodes with an exposed
changedfilter, operator>=, granularity "second". - Pass
2026-10-12T15:23:23Z, the same moment as@1791818603or2026-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
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
Comment #2
fagoComment #3
fagoComment #5
fagocreated MR with fix and test-coverage
Comment #6
fagothere are some phpstan fails, but those seem to be not in the files I touched.
Comment #8
mandclu commentedI 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.