[php-src] Issue #11368: Date modify returns invalid datetime

From: Date: Sun, 04 Jun 2023 12:55:28 +0000
Subject: [php-src] Issue #11368: Date modify returns invalid datetime
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244596@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11368 Author: adamwpe ### Description The following code: ```php <?php $datetime = date_create('now'); $datetime->setTime(1,1,1,1 /* If set to any other number, it works fine */); $datetime->modify('-100 ms'); var_dump($datetime); ``` Resulted in this output: ``` object(DateTime)#1 (3) { ["date"]=> string(26) "2023-06-04 01:01:01.-99999" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ``` But I expected this output instead: ``` object(DateTime)#1 (3) { ["date"]=> string(26) "2023-06-03 23:59:59.900000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } ``` ### PHP Version 8.1.19 ### Operating System _No response_

« previous php.bugs (#244596) next »