|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-10-31 09:48 UTC] info at milinka dot co dot uk
Description:
------------
NOTE: This bug can replicated only today. 31 Oct 2017.
When adding +1 month using DateTime, it returns incorrect DateTime.
Code:
$begin = new DateTime("now");
$end = clone $begin;
$end->modify("+1 month");
var_dump($begin,$end);
Outputs dates, where end date is wrong:
object(DateTime)#1 (3) {
["date"]=>
string(26) "2017-10-31 02:41:11.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
object(DateTime)#2 (3) {
["date"]=>
string(26) "2017-12-01 02:41:11.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
Test script:
---------------
$begin = new DateTime("now");
$end = clone $begin;
$end->modify("+1 month");
var_dump($begin,$end);
Expected result:
----------------
object(DateTime)#1 (3) {
["date"]=>
string(26) "2017-10-31 02:41:11.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
object(DateTime)#2 (3) {
["date"]=>
string(26) "2017-11-30 02:41:11.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
Actual result:
--------------
object(DateTime)#1 (3) {
["date"]=>
string(26) "2017-10-31 02:41:11.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
object(DateTime)#2 (3) {
["date"]=>
string(26) "2017-12-01 02:41:11.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 21:00:01 2025 UTC |
$date = new DateTime(); $date->setDate(2017, 1, 31); $date->modify("+1 months"); var_dump($date->format('d.m.Y')); --> "2017-03-03 03:25:01.010311"