diff --git a/app/Models/PatientModel.php b/app/Models/PatientModel.php index d97eb0d..b661d6e 100644 --- a/app/Models/PatientModel.php +++ b/app/Models/PatientModel.php @@ -344,12 +344,17 @@ class PatientModel extends Model { } // Conversion Time to Format Y-m-d\TH:i:s\Z - private function formatedDate($dateString) { - // return $date->format('Y-m-d H:i'); - $dt = new \DateTime($dateString, new \DateTimeZone("UTC")); + private function formattedDate(?string $dateString): ?string { + try { + if (empty($dateString)) { + return null; + } - // Format jadi ISO 8601 dengan 'Z' - return $dt->format('Y-m-d\TH:i:s\Z'); + $dt = new \DateTime($dateString, new \DateTimeZone("UTC")); + return $dt->format('Y-m-d\TH:i:s\Z'); // ISO 8601 UTC + } catch (\Exception $e) { + return null; + } } // Conversion Time to Format j M Y