Home > Software engineering >  Laravel how to sum carbon now with date input in a blade file
Laravel how to sum carbon now with date input in a blade file

Time:08-01

I am trying to sum Carbon\Carbon::now() in blade with a date input from database in a blade file.

My code is:

{{Carbon\Carbon::now()      $uses2->data2pasaport }}

But it returns this error:

Unsupported operand types: Carbon\Carbon   string

Any suggestion on how to fix this?

CodePudding user response:

To find time difference between two dates you can use diffInDays like:

$date = Carbon::parse($uses2->data2pasaport);
$now = Carbon::now();

$diff = $date->diffInDays($now); // difference between dates with days
  • Related