HTML CSS JavaScript jQuery AJAX ASP PHP SQL tutorials, examples for web building ,author kapil kumar: November 2014

Sunday 30 November 2014

Age calculation in php

Age calculation in php



Declare a function =>

  1. function getAge( $dob, $date )
  2. {
  3.     $dob=strtotime($dob);
  4.     $date=strtotime($date);
  5.         $age = 0;
  6.         while( $date > $dob = strtotime('+1 year', $dob))
  7.         {
  8.                 ++$age;
  9.         }
  10.         return $age." years";
  11. }