I am explaining you, how to calculate number of Age from date of birth in PHP. if you want to show user’s age from date of birth so you can use this process and show Age in php. here I will use some function like date(), date_create() and date_diff() that need to used to calculate the age from date of birth in PHP. it is simple process.
Example :
<?php
$UsersdateOfBirth = "20-10-2001";
$currentDate = date("Y-m-d");//like 18-12-2022
$Calculatediff = date_diff(date_create($UsersdateOfBirth), date_create($currentDate));
echo 'Here, User age is '.$Calculatediff->format('%y');
?>
Output :
Here, User age is 21
Hello, Welcome to webdeveloperindia.in. I am a full-stack web developer. Email – [email protected] | Skype – azaruddin23. I have knowledge of PHP, Laravel, Magento 1/2, Codeigniter, WordPress, Joomla, Shopify, Git, Bitbuket, jQuery, Ajax, Javascript and ReactJS.