Carbon: floatDiffInMonths not working correctly
Hello,
I encountered an issue with the following code:
echo Carbon::parse('2000-01-15 00:00')->floatDiffInMonths('2000-02-20 00:00');
Carbon version: master of github PHP version: 7.1.3
I expected to get:
any value more than 1
But I actually get:
0.82758620689655
I tried with other dates as well and it seems to have issue. Like:
echo Carbon::parse('2018-12-16 00:00')->floatDiffInMonths('2019-12-15 00:00');
Above code must output a floating value nearing to 12 but instead output shows 10.048387096774
Thanks!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 22
Commits related to this issue
- Test issue #1490 — committed to kylekatarnls/Carbon by kylekatarnls 6 years ago
- Merge pull request #1492 from kylekatarnls/test-issue1490 Add tests for #1490 — committed to briannesbitt/Carbon by kylekatarnls 6 years ago
Awesome to finally know the root cause! Great job. I hope this will help other people.
For the record, we will no longer support the method using
DateTime::diff
in Carbon 3, “real” method will replace the default one. #2119