bazie
1648
4
Laravel

calculate age from birthday

Posted 2 years ago by bazie

Hello, I want to find the age in laravel from birthday I use carbon but nothing interresting.

$now=  Carbon::now();
$patient->dateNaissance = $input['anneeNaissance'].'-'.$input['moisNaissance'].'-'.$input['jourNaissance'];

$age=$now-$patient->dateNaissance;
        dd($age);

But I get this error

ErrorException in PatientController.php line 77: Object of class Carbon\Carbon could not be converted to int

Please sign in or create an account to participate in this conversation.