3 C
New York
Sunday, December 4, 2022

Laravel age calculate from date using carbon





In this small tutorial, i will show you how to calculate age from date using carbon in laravel 5, laravel 6, laravel 7 and laravel 8 application.

If you work on big web application then you might be sometime require to age calculate from date of birth. Like your birth date is around 02/07/1994 and today date like 10/9/2018 then it should be return 24 years old you are.

So, you can simply age calculation by using laravel carbon. So just see example:

Example:

$dateOfBirth = '1994-07-02';

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

dd($years);

I hope it can help you…

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles