[php-src] Issue #9891: DateTime modify with unixtimestamp (@) must works like setTimestamp

From: Date: Fri, 04 Nov 2022 14:16:07 +0000
Subject: [php-src] Issue #9891: DateTime modify with unixtimestamp (@) must works like setTimestamp
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242750@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9891 Author: goncons ### Description The following code: ```php <?php $a = new DateTime('2022-11-01 13:30:00', new DateTimezone('America/Lima')); $b = clone $a; echo '$a: ', $a->format(DateTime::ATOM), "\r\n"; echo '$b: ', $b->format(DateTime::ATOM), "\r\n"; echo '$a: @', $a->getTimestamp(), "\r\n"; echo '$b: setTimestamp(', $b->getTimestamp(), ")\r\n"; $a->modify('@' . $a->getTimestamp()); $b->setTimestamp($b->getTimestamp()); echo '$a: ', $a->format(DateTime::ATOM), "\r\n"; echo '$b: ', $b->format(DateTime::ATOM), "\r\n"; ``` Resulted in this output: ``` $a: 2022-11-01T13:30:00-05:00 $b: 2022-11-01T13:30:00-05:00 $a: @1667327400 $b: setTimestamp(1667327400) $a: 2022-11-01T18:30:00-05:00 $b: 2022-11-01T13:30:00-05:00 ``` But I expected this output instead: ``` $a: 2022-11-01T13:30:00-05:00 $b: 2022-11-01T13:30:00-05:00 $a: @1667327400 $b: setTimestamp(1667327400) $a: 2022-11-01T13:30:00-05:00 $b: 2022-11-01T13:30:00-05:00 ``` ### PHP Version PHP 8.1.12 ### Operating System _No response_

« previous php.bugs (#242750) next »