Program :
<html><body>
<form action="welcome.php" method="post">
DOB: <input type="text" name="dob"><br>
<input type="submit">
</form>
</body>
</html>
File name : welcome.php
<?php$birthDate=$_POST["dob"];
//explode the date to get month, day and year
$birthDate = explode("/", $birthDate);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
? ((date("Y") - $birthDate[2]) - 1)
: (date("Y") - $birthDate[2]));
echo "Age is:" . $age;
//$date1=getAge($birthday);
?>
Output :
0 comments:
Post a Comment