age calculator using php

Age calculator using PHP

Using simple php and html code we can create a age calculation program.for that you need XAMPP,WAMP or local server in your computer.After starting xampp application you need to create form

<form method="post" action="check_age.php">
    <div class="form-group">
      <label for="date">Date of Birth:</label>
      <input type="date" class="form-control" id="date_of_birth" placeholder="Enter date" name="Dob">
    <button type="submit" class="btn btn-default">Check Age</button>

Then you need to add some php code in check_age.php. The above form action will pass to check_age.php when form button action take place. Mainly i am using to date functions they are date_create() and date_diff().By using these function we can find the age

 if(isset($_POST['submit']) {
  $age=date_diff(date_create($dob), date_create('today'))->y;
  echo "Your age is ".$age;

About the author

Junaid V J

My self Junaid . This Blog is a platform to gain immense knowledge of web development. Modern web designing and development can be acquired through this. Specialized in HTML, PHP, CSS, JAVASCRIPT , BOOTSTRAP,WORDPRESS, CODEIGNITER.

View all posts


Leave a Reply

Your email address will not be published. Required fields are marked *