Advertisement
GWibisono

DoB

Jul 22nd, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.     $dob=$patData[pat_birth];
  3.         list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $dob);
  4.         // Find the differences
  5.         $YearDiff = date("Y") - $BirthYear;
  6.          //echo $YearDiff;
  7.         $MonthDiff = date("m") - $BirthMonth;
  8.          
  9.         //echo $MonthDiff;
  10.         $DayDiff = date("d") - $BirthDay;
  11.         // If the birthday has not occured this year
  12.         if ($DayDiff < 0 || $MonthDiff < 0)
  13.           $YearDiff--;          
  14.         if($MonthDiff<0)$MonthDiff+=12;
  15.         $age= "$YearDiff Tahun $MonthDiff Bulan";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement