xxxxxxxxxx
$dt = Carbon::create(2012, 1, 31, 0);
$future = Carbon::create(2012, 1, 31, 0);
$future = $future->addMonth();
echo $dt->diffInDays($future); //31
xxxxxxxxxx
use Carbon\Carbon
Carbon::parse()->parse('2022-09-20')->diffInHours(Carbon::parse()->parse('2022-09-21 10:50'));
// 34
xxxxxxxxxx
$start = new Carbon('2018-10-04 15:00:03');
$end = new Carbon('2018-10-05 17:00:09');
You may use
$start->diff($end)->format('%H:%I:%S');
which gives the difference modulo 24h
02:00:06
If you want to have the difference with more than 24h, you may use :
$start->diffInHours($end) . ':' . $start->diff($end)->format('%I:%S');
xxxxxxxxxx
I ended up grabbing the total seconds difference using Carbon:
$totalDuration = $finishTime->diffInSeconds($startTime);
// 21
Then used gmdate:
gmdate('H:i:s', $totalDuration);
// 00:00:21
xxxxxxxxxx
Carbon::createFromDate(1991, 7, 19)->diff(Carbon::now())->format('%y years, %m months and %d days')
// => "23 years, 6 months and 26 days"