|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67634 getTimestamp() modify instance of DateTimeImmutable
Submitted: 2014-07-16 15:28 UTC Modified: 2019-10-23 13:34 UTC
Avg. Score:3.2 ± 1.9
Reproduced:9 of 21 (42.9%)
Same Version:3 (33.3%)
Same OS:6 (66.7%)
From: mathieu at rochette dot cc Assigned: cmb (profile)
Status: Closed Package: Date/time related
PHP Version: 5.5.14 OS: ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mathieu at rochette dot cc
New email:
PHP Version: OS:


 [2014-07-16 15:28 UTC] mathieu at rochette dot cc
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:

$date = new DateTimeImmutable('2014-05');

$date2 = $date->modify('first day of next month midnight - 1 second');


Expected result:
string(25) "2014-05-31T23:59:59+00:00"
string(10) "1401580799"
string(25) "2014-05-31T23:59:59+00:00"
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"
string(10) "1398988799"
string(25) "2014-05-01T23:59:59+00:00"


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-16 19:19 UTC] sjon at hortensius dot net
This bug is present in all php-versions including php7:

The bug can also be simplified to; where it shows that the ->modify() call is irrelevant
 [2019-10-06 22:15 UTC] aleh dot kashnikau at gmail dot com
Bug is still present in 7 version:
 [2019-10-23 13:34 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2019-10-23 13:34 UTC]
This bug is already been fixed as of PHP 7.0.4, see <>.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 01 13:01:23 2020 UTC