calculate age from date of birth and display it. The PHP date function is used to format a date. here we can learn to main 2 Examples.
calculate age from date of birth in PHP
Calculate Age to $Date of Birth can be done in many ways. The following source code will calculates age from date of birth.
<?php $dob='1994-07-01'; $year = (date('Y') - date('Y',strtotime($dob))); echo $year; ?>
don’t miss : Get Previous Date From Given Date In Php
<?php $dob = new DateTime('1994-07-01'); $today = new DateTime('today'); $year = $dob->diff($today)->y; echo $year; ?>
I hope you get an idea about calculate age from date of birth.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.