From 7623f633e648332f848dd28ef1f99644d1a9f786 Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Mon, 11 Aug 2025 20:58:31 +0700 Subject: [PATCH] Update Patient show, menambahkan method untuk hitung usia pasien --- app/Controllers/Patient.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index ec61b18..ffd0a4e 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -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; }