mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
refactor: use $this->difference()
This commit is contained in:
parent
efef8eb702
commit
4e7c3df956
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user