Bug #67634 [NEW]: getTimestamp() modify instance of DateTimeImmutable
| From: | mathieu at rochette dot cc | Date: | Wed, 16 Jul 2014 15:28:41 +0000 |
| Subject: | Bug #67634 [NEW]: getTimestamp() modify instance of DateTimeImmutable | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186672@lists.php.net to get a copy of this message | ||
From: mathieu at rochette dot cc
Operating system: ubuntu
PHP version: 5.5.14
Package: Date/time related
Bug Type: Bug
Bug description:getTimestamp() modify instance of DateTimeImmutable
Description:
------------
calling getTimestamp() on an instance of a DateTimeImmutable modify it
(and return the modified date timestamp).
calling format('U') does not modify the date
Test script:
---------------
<?php
$date = new DateTimeImmutable('2014-05');
$date2 = $date->modify('first day of next month midnight - 1 second');
var_dump($date2->format('c'));
var_dump($date2->format('U'));
var_dump($date2->format('c'));
var_dump($date2->getTimestamp());
var_dump($date2->format('U'));
var_dump($date2->format('c'));
Expected result:
----------------
string(25) "2014-05-31T23:59:59+00:00"
string(10) "1401580799"
string(25) "2014-05-31T23:59:59+00:00"
int(1401580799)
string(10) "1401580799"
string(25) "2014-05-31T23:59:59+00:00"
Actual result:
--------------
string(25) "2014-05-31T23:59:59+00:00"
string(10) "1401580799"
string(25) "2014-05-31T23:59:59+00:00"
int(1398988799)
string(10) "1398988799"
string(25) "2014-05-01T23:59:59+00:00"
--
Edit bug report at https://bugs.php.net/bug.php?id=67634&edit=1
--