From 4e7c3df956dc587ac543770a2d3d7ff7c3e04774 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 21 Jun 2022 15:55:07 +0900 Subject: [PATCH] refactor: use $this->difference() --- system/I18n/Time.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/system/I18n/Time.php b/system/I18n/Time.php index 77141a840e..dd26979af1 100644 --- a/system/I18n/Time.php +++ b/system/I18n/Time.php @@ -460,12 +460,8 @@ class Time extends DateTime */ public function getAge() { - $now = self::now(); - - $age = (int) (((int) $now->format('Ymd') - (int) $this->format('Ymd')) / 10000); - // future dates have no age - return max(0, $age); + return max(0, $this->difference(self::now())->getYears()); } /**