public function formatDiff(DateTimeInterface $from, DateTimeInterface $to)
    {
        static $units = array(
            'y' => 'year',
            'm' => 'month',
            'd' => 'day',
            'h' => 'hour',
            'i' => 'minute',
            's' => 'second'
        );

        $diff = $to->diff($from);

        foreach ($units as $attribute => $unit) {
            $count = $diff->$attribute;
            if (0 !== $count) {
                return $this->doGetDiffMessage($count, $diff->invert, $unit);
            }
        }

        return $this->getEmptyDiffMessage();
    }
public function formatDiff(DateTimeInterface $from, DateTimeInterface $to)
    {
        static $units = array(
            'y' => 'year',
            'm' => 'month',
            'd' => 'day',
            'h' => 'hour',
            'i' => 'minute',
            's' => 'second'
        );

        $diff = $to->diff($from);

        foreach ($units as $attribute => $unit) {
            $count = $diff->$attribute;
            if (0 !== $count) {
                return $this->doGetDiffMessage($count, $diff->invert, $unit);
            }
        }

        return $this->getEmptyDiffMessage();
    }
public function formatDiff ( DateTimeInterface $ from , DateTimeInterface $ to ) { static $ units = array ( 'y' => 'year' , 'm' => 'month' , 'd' => 'day' , 'h' => 'hour' , 'i' => 'minute' , 's' => 'second' ) ; $ diff = $ to -> diff ( $ from ) ; foreach ( $ units as $ attribute => $ unit ) { $ count = $ diff -> $ attribute ; if ( 0 !== $ count ) { return $ this -> doGetDiffMessage ( $ count , $ diff -> invert , $ unit ) ; } } return $ this -> getEmptyDiffMessage ( ) ; }
Returns a formatted diff for the given from and to datetimes

@param  DateTimeInterface $from
@param  DateTimeInterface $to

@return string
Returns a formatted diff for the given from and to datetimes