$date = Carbon::parse(Carbon::parse('2016-01-31 00:00:00')->addMonth()->format('Y-m-t'));
Yes that is based on the PHP implementaion. You can use addMonthsNoOverflow if you don't wan't the default overflow to occur.
The PHP implementation is crazy - March is fine, but the 2nd of March? It should be the 1st March.
addMonthsNoOverflow() takes you from a rock, to a hard place - it also uses logic that is incorrect IMO. Adding one calendar month should take you to the start of the next calendar month. Taking one day off that will take you to the last day of the current calendar month.
So 2016-01-31 -> addMonthsNoOverflow(1) takes you to 29 February. Taking one day off that is the last day of the calendar month starting 2016-01-31, and that gives us 28 February. That seems wrong to me. Why wouldn't the last day of that calendar month be the last day of the shorter month, i.e. 29 February?
See #710
Most helpful comment
Yes that is based on the PHP implementaion. You can use
addMonthsNoOverflowif you don't wan't the default overflow to occur.