Update Patient show, menambahkan method untuk hitung usia pasien

This commit is contained in:
mikael-zakaria 2025-08-11 20:58:31 +07:00
parent 46b87b8dde
commit 7623f633e6

View File

@ -398,7 +398,17 @@ class Patient extends Controller {
$today = new \DateTime();
$diff = $today->diff($dob);
$formattedAge = "{$diff->y} years {$diff->m} months {$diff->d} days";
$formattedAge = "";
if ($diff->y > 0){
$formattedAge .= "{$diff->y} Tahun ";
}
if ($diff->m > 0){
$formattedAge .= "{$diff->m} Bulan ";
}
if ($diff->d > 0){
$formattedAge .= "{$diff->d} Hari ";
}
return $formattedAge;
}