[php-src] PR #21669: Fix GH-21616: DateTime::modify() wrong timestamp across DST transitions
| From: | MarcusXavierr | Date: | Wed, 08 Apr 2026 03:47:04 +0000 |
| Subject: | [php-src] PR #21669: Fix GH-21616: DateTime::modify() wrong timestamp across DST transitions | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35615@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21669
Author: MarcusXavierr
DateTime::modify() with relative h/i/s strings produces wrong timestamps near DST
transitions.
do_adjust_relative() adds hours, minutes, and seconds to wall-clock fields before
timelib_update_ts() converts to a Unix timestamp. Near a spring-forward gap, that
intermediate wall-clock time is ambiguous and resolves to the wrong side.
add()/sub() don't have this problem —
timelib_add_wall() adds h/i/s directly to SSE.
In php_date_modify(), strip h, i, s, and
us from the relative struct before timelib_update_ts(), then apply them
via sse += afterward. Full seconds are
extracted from any microsecond overflow before the SSE step. timelib_update_ts() still
handles y/m/d, weekdays, and special relatives, so calendar strings like `'+3
days' and 'first day of next month'` are unaffected.
Fixes GH-21616.
Fixes GH-15880.