Advertisement
fadlyshafa

Untitled

Oct 5th, 2019
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. function hitung_umur($tanggal_lahir) {
  2.         list($year,$month,$day) = explode("-",$tanggal_lahir);
  3.         $year_diff  = date("Y") - $year;
  4.         $month_diff = date("m") - $month;
  5.         $day_diff   = date("d") - $day;
  6.         if ($month_diff < 0) $year_diff--;
  7.         elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--;
  8.         return $year_diff.' tahun '.$month_diff.' bulan '.$day_diff.' hari';
  9.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement