diff --git a/core/src/Core.php b/core/src/Core.php index a05408126b..1d2061e943 100644 --- a/core/src/Core.php +++ b/core/src/Core.php @@ -5036,7 +5036,7 @@ public function toTimeStamp($str) $M = 0; $S = 0; } - $timeStamp = mktime($H, $M, $S, $m, $d, $Y); + $timeStamp = gmmktime($H, $M, $S, $m, $d, $Y); $timeStamp = (int) $timeStamp; return $timeStamp; } diff --git a/core/tests/Unit/CoreTest.php b/core/tests/Unit/CoreTest.php index 3f83f8fd18..653b57ad3c 100644 --- a/core/tests/Unit/CoreTest.php +++ b/core/tests/Unit/CoreTest.php @@ -73,6 +73,24 @@ Mockery::close(); }); +test('date conversion round trips without runtime timezone drift', function () { + $originalTimezone = date_default_timezone_get(); + + try { + date_default_timezone_set('Asia/Tokyo'); + $this->parser->config['datetime_format'] = 'YYYY/mm/dd'; + + $date = '2026/09/01 10:00:00'; + $timestamp = $this->parser->toTimeStamp($date); + + expect($this->parser->toDateFormat($timestamp))->toBe($date) + ->and($this->parser->toDateFormat($this->parser->toTimeStamp($this->parser->toDateFormat($timestamp)))) + ->toBe($date); + } finally { + date_default_timezone_set($originalTimezone); + } +}); + describe('getTagsFromContent', function () { test('it extracts basic placeholders correctly', function () {