public getDifferenceInYears ( ExpressiveDate $compare = null ) : string | ||
$compare | ExpressiveDate | |
리턴 | string |
public function getDifferenceInYears($compare = null)
{
if (!$compare) {
$compare = new ExpressiveDate(null, $this->getTimezone());
}
return $this->diff($compare)->format('%r%y');
}
public function testGetDateDifferenceInYears() { $past = new ExpressiveDate('January 2010'); $future = new ExpressiveDate('January 2013'); $this->assertEquals(-3, $future->getDifferenceInYears($past)); $this->assertEquals(3, $past->getDifferenceInYears($future)); }