Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dob=$patData[pat_birth];
- list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $dob);
- // Find the differences
- $YearDiff = date("Y") - $BirthYear;
- //echo $YearDiff;
- $MonthDiff = date("m") - $BirthMonth;
- //echo $MonthDiff;
- $DayDiff = date("d") - $BirthDay;
- // If the birthday has not occured this year
- if ($DayDiff < 0 || $MonthDiff < 0)
- $YearDiff--;
- if($MonthDiff<0)$MonthDiff+=12;
- $age= "$YearDiff Tahun $MonthDiff Bulan";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement