Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我在几天内获得差异的代码
$endDate = Carbon::parse($input['to_date']); $startDate = Carbon::parse($input['from_date']); $rentDays = $startDate->diffInDays($endDate);
例如。fromdate= '29-11-2021' 和 to date ='03-12-2021' 它返回 4 天。我想要5天
你可以用这个
$rentDays = $startDate->diffInDays($endDate) + 1;
或者
$rentDays = $startDate->diffInDays($endDate->addDays(1));