-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CarbonInterval
's days
property return false
#3018
Comments
Before the 3.0, the As stated in the
It's a problem for the @daniser You can replace all the |
You can also use |
This breaks compatibility with the package simshaun/recurr. If we set a You should use Example usage in Recurr package here. |
This doesn't just affect Note that in the example below, the $now = Carbon::now();
$newDate = Carbon::now()
->subDays(4);
$d1 = $now->diff($newDate)->hours;
$d2 = $now->diffInHours($newDate);
echo 'diff: ' . $d1 . PHP_EOL;
echo 'diffInHours: ' . $d2 . PHP_EOL;
/**
* Output:
* diff: 23 // not even remotely correct
* diffInHours: -95.999999995278 // correct
*/ Edit: I see Edit 2: Okay, it's the current hour, as in, the 23 hours at which I ran the command (which I did not notice because I am not in UTC). But in that case, I think the description of the diff interval needs some work, because it seems to indicate the number of hours difference, not the hour-on-the-clock after you add/sub the difference. |
Hello,
No, 23 is the hours component of the diff in 3 days, 23 hours as you guessed, it's not negative because the whole interval is. This is unrelated to this issue and this behavior directly comes from PHP itself from DateTime::diff. This is also the reason why we won't "get rid of I suggest you
Indeed, this is wrong, we should fix this. |
What I meant was that this ended up at 23 because I ran the
Cool, because this was the whole reason I made these wrong assumptions in the first place. |
Documentation will be fixed via #3130 |
Hello,
I encountered an issue with the following code:
3
false
Carbon version: 3.3.1
PHP version: 8.3.4
I expected to get:
But I actually get:
Thanks!
The text was updated successfully, but these errors were encountered: