Reputation: 1990
I need to show the passed years like 5.6
years with a given date $model->created_at
What I tried so far is
$dt = Carbon::now();
echo $dt->diffForHumans($model->created_at); 1 month ago
how to show date only like 5.6 years
Upvotes: 0
Views: 390
Reputation: 12188
you can use Carbon::floatDiffInRealYears
to get exactly the different,
and Carbon::diffInYears
to get the rounded result of the previous method
$dt = Carbon::now();
echo $dt->floatDiffInRealYears($model->created_at);
Upvotes: 2