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.
Example:
$myDate = '1995-07-02';
$years = \Carbon::parse($myDate)->age;
dd($years);
Output:
23
I hope you found your best...
Do you like below Tutorials ?
- Angular Use CKEditor Example Tutorial
- How to Use Multiple Select Dropdown in Laravel?
- Angular 9 Image Upload with Crop Example
- Files Upload on Button Click in PHP Dropzone Example
- PHP Dropzone Allow only One File to Upload Example
- PHP Dropzone Allow only Images to Upload Example
- PHP Dropzone Delete Uploaded File Example
- Livewire CRUD Laravel 7 Example