添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

Hello, i cant get negative differences between two dates (only positive)

Carbon::createFromDate(1975, 5, 21)->diffInDays(Carbon::today())
Carbon::today()->diffInDays(Carbon::createFromDate(1975, 5, 21))

return equal values, but one of those should be negative :?

As shown in the readme ( https://github.com/briannesbitt/Carbon/#difference ) you can pass false as the 2nd param to not return the absolute value.

"The 2nd parameter again is optional and indicates if you want the return value to be the absolute value or a relative value that might have a - (negative) sign if the passed in date is less than the current instance. This will default to true, return the absolute value."

thukuwanjiku, roerjo, Pezhvak, NikitaKharkov, jaumebalust, yugen, keliix06, sonemaro, kaleazy, nelson6e65, and 21 more reacted with thumbs up emoji JCarlosR, RamonSmit, YavorK, rkukuh, chilio, jankremlacek, beingmohit, andhu, ahhmarr, jinoantony, and 12 more reacted with hooray emoji imanhmz and RoduanKD reacted with heart emoji All reactions