Carbon: Error in calculating previous/next months
$month = new Carbon('2016-05');
$month-> endOfMonth(); // updated
[
'month' => $month,
'monthPrev' => $month->copy()->subMonth(),
'monthNext' => $month->copy()->addMonth(),
]
Dump:
"month" => Carbon {#233 ▼
+"date": "2016-05-31 23:59:59.000000"
+"timezone_type": 3
+"timezone": "UTC"
}
"monthPrev" => Carbon {#241 ▼
+"date": "2016-05-01 23:59:59.000000"
+"timezone_type": 3
+"timezone": "UTC"
}
"monthNext" => Carbon {#234 ▼
+"date": "2016-07-01 23:59:59.000000"
+"timezone_type": 3
+"timezone": "UTC"
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (1 by maintainers)
Did you try with
addMonthNoOverflow@terion-name ?Yes, it would be a breaking change… Well, while it is not possible to change behaviour for
1.x, can you please addaddMonthNoOverflowandsubMonthNoOverflowto the docs?Hi, I’m here from the future, and just ran into this the hard way. Please can you mention add/subMonthNoOverflow in the docs? Thank you a lot!