I am working on datetime. I need the age between two date. Date1 retrieve from database while date2 is today.Below is the code:
while($row= mysqli_fetch_array($query)){
    $surname=$row['surname'];
    $firstname= $row['firstname'];
    $othername=$row['othername'];
    $sex= $row['sex'];
    $regdate= $row['reg_date'];
}
then this is code for table display:
<tr>
    <td>Years in Service</td>
    <td><?php 
    $date1 = new DateTime("Y-m-d");
    $date2 = new DateTime("$regdate");
    $interval = $date1->diff($date2);
    echo  $interval->y . " years, " . $interval->m." months, ".$interval->d." days ";   
    ?></td>
</tr>
 
     
     
     
    