I want to show retirement of current month by date of birth. I have a column dob (format is 1960-12-21). Now I have to calculate 60 years from dob by current month. If current month is October 2020 and date of birth is 1960-09-21 then records should be fetch. Today's date doesn't matter. But if month is September 2020 OR November 2020 then data should not show.
Records should be fetch by current month, if current month completes 60 years.
Means results should be:
Retirement of this month is: abc,xyz etc.
I tried, but I am not getting my results:
Controller is:
public function index()
{
$retirement = User::select('name','dob')->get();
foreach($retirement as $retirement)
{
echo Carbon::parse($retirement->dob)->age;
}
}
It shows years only.