|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63940 DateTime->modify(last day of ) not working properly for December
Submitted: 2013-01-08 15:32 UTC Modified: 2015-05-10 04:22 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: carlos dot jimene dot guirao at gmail dot com Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.3.20 OS: Ubuntu 10.04.4 LTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: carlos dot jimene dot guirao at gmail dot com
New email:
PHP Version: OS:


 [2013-01-08 15:32 UTC] carlos dot jimene dot guirao at gmail dot com
Working with DateTime object as shown on manual.

If you modify a DateTime object using this relative format "last day of December Year" it fails giving instead last day of next January.

It seems that it was corrected when used in DateTime Constructor instead. So if you create DateTime object using same string in constructor it works.

Test script:
$datetime = new DateTime();
$datetime->modify('last day of December 2012');

$anotherdt = new DateTime('last day of December 2012');

Expected result:
string(10) "2012-12-31"
string(10) "2012-12-31"

Actual result:
string(10) "2013-01-31"
string(10) "2012-12-31"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-08 15:37 UTC] carlos dot jimenez dot guirao at gmail dot com
In php version PHP 5.4.6
OS:	Ubuntu 12.10

Same script outputs:
string(10) "2012-12-31"
string(10) "2012-12-31"

Results working as expected.
 [2015-04-20 03:29 UTC]

Output for hhvm-3.5.0 - 3.6.1
string(10) "2012-12-01"
string(10) "2012-12-31"

Output for 5.3.6 - 5.6.8, php7@20140507 - 20150401
string(10) "2012-12-31"
string(10) "2012-12-31"

Output for 5.3.0 - 5.3.5
string(10) "2015-04-30"
string(10) "2012-12-31"

* 5.3 is eol and seems to work on current versions
 [2015-04-27 23:17 UTC]
-Status: Open +Status: Feedback
 [2015-04-27 23:17 UTC]
This issue might dependent on the timezone. Which one do you have
set, Carlos?

 [2015-05-10 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Dec 05 12:03:38 2021 UTC