HTML CSS JavaScript jQuery AJAX ASP PHP SQL tutorials, examples for web building ,author kapil kumar: Age calculation in php
Pages
Home
About Kapil Kumar
Sunday, 30 November 2014
Age calculation in php
Age calculation in php
Declare a function =>
function getAge( $dob, $date )
{
$dob=strtotime($dob);
$date=strtotime($date);
$age = 0;
while( $date > $dob = strtotime('+1 year', $dob))
{
++$age;
}
return $age." years";
}
Assign values to variables=>
$dob= "01-07-1991";
$today_date=date("d-m-Y");
Call the function =>
echo "Total age ". getAge($dob,$today_date);
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment