Calculate age from date of birth in Laravel

Hi Guys,

Today, we will learn to calculate age from birthdate in laravel application. we will use carbon to calculate age in laravel.

Actually, yesterday i was working on my laravel 5 application and i require to display age from date of birth in laravel project. I thought i need to use date helper function on php. but i found carbon to calculate age in laravel and we don't require to install carbon in laravel because it is already installed.

So, here is a very simple example for age calculation in laravel.


$myDate = '1995-07-02';

$years = \Carbon::parse($myDate)->age;




I hope you found your best...

September 11, 2018 | Category : PHP Laravel
Related Posts