public function inWords($seconds)
    {
        $prefix = $this->data['prefixAgo'];
        $suffix = $this->data['suffixAgo'];
        if ($this->allowFuture && $seconds < 0) {
            $prefix = $this->data['prefixFromNow'];
            $suffix = $this->data['suffixFromNow'];
        }

        $seconds = abs($seconds);

        $minutes = $seconds / 60;
        $hours = $minutes / 60;
        $days = $hours / 24;
        $years = $days / 365;

        $separator = $this->data['wordSeparator'] === null ? " " : $this->data['wordSeparator'];

        $wordsConds = array(
            $seconds < 45,
            $seconds < 90,
            $minutes < 45,
            $minutes < 90,
            $hours < 24,
            $hours < 42,
            $days < 30,
            $days < 45,
            $days < 365,
            $years < 1.5,
            true
        );

        $wordResults = array(
            array('seconds', round($seconds)),
            array('minute', 1),
            array('minutes', round($minutes)),
            array('hour', 1),
            array('hours', round($hours)),
            array('day', 1),
            array('days', round($days)),
            array('month', 1),
            array('months', round($days / 30)),
            array('year', 1),
            array('years', round($years))
        );

        for ($i = 0; $i < $count = count($wordsConds); ++$i) {
            if ($wordsConds[$i]) {
                $key = $wordResults[$i][0];
                $number = $wordResults[$i][1];
                if (is_array($this->data[$key]) && is_callable($this->data['rules'])) {
                    $n = call_user_func($this->data['rules'], $wordResults[$i][1]);
                    $message = $this->data[$key][$n];
                } else {
                    $message = $this->data[$key];
                }
                return trim(implode($separator, array($prefix, preg_replace('/%d/i', $number, $message), $suffix)));
            }
        }
    }
public function inWords($seconds)
    {
        $prefix = $this->data['prefixAgo'];
        $suffix = $this->data['suffixAgo'];
        if ($this->allowFuture && $seconds < 0) {
            $prefix = $this->data['prefixFromNow'];
            $suffix = $this->data['suffixFromNow'];
        }

        $seconds = abs($seconds);

        $minutes = $seconds / 60;
        $hours = $minutes / 60;
        $days = $hours / 24;
        $years = $days / 365;

        $separator = $this->data['wordSeparator'] === null ? " " : $this->data['wordSeparator'];

        $wordsConds = array(
            $seconds < 45,
            $seconds < 90,
            $minutes < 45,
            $minutes < 90,
            $hours < 24,
            $hours < 42,
            $days < 30,
            $days < 45,
            $days < 365,
            $years < 1.5,
            true
        );

        $wordResults = array(
            array('seconds', round($seconds)),
            array('minute', 1),
            array('minutes', round($minutes)),
            array('hour', 1),
            array('hours', round($hours)),
            array('day', 1),
            array('days', round($days)),
            array('month', 1),
            array('months', round($days / 30)),
            array('year', 1),
            array('years', round($years))
        );

        for ($i = 0; $i < $count = count($wordsConds); ++$i) {
            if ($wordsConds[$i]) {
                $key = $wordResults[$i][0];
                $number = $wordResults[$i][1];
                if (is_array($this->data[$key]) && is_callable($this->data['rules'])) {
                    $n = call_user_func($this->data['rules'], $wordResults[$i][1]);
                    $message = $this->data[$key][$n];
                } else {
                    $message = $this->data[$key];
                }
                return trim(implode($separator, array($prefix, preg_replace('/%d/i', $number, $message), $suffix)));
            }
        }
    }
public function inWords ( $ seconds ) { $ prefix = $ this -> data [ 'prefixAgo' ] ; $ suffix = $ this -> data [ 'suffixAgo' ] ; if ( $ this -> allowFuture && $ seconds < 0 ) { $ prefix = $ this -> data [ 'prefixFromNow' ] ; $ suffix = $ this -> data [ 'suffixFromNow' ] ; } $ seconds = abs ( $ seconds ) ; $ minutes = $ seconds / 60 ; $ hours = $ minutes / 60 ; $ days = $ hours / 24 ; $ years = $ days / 365 ; $ separator = $ this -> data [ 'wordSeparator' ] === null ? " " : $ this -> data [ 'wordSeparator' ] ; $ wordsConds = array ( $ seconds < 45 , $ seconds < 90 , $ minutes < 45 , $ minutes < 90 , $ hours < 24 , $ hours < 42 , $ days < 30 , $ days < 45 , $ days < 365 , $ years < 1.5 , true ) ; $ wordResults = array ( array ( 'seconds' , round ( $ seconds ) ) , array ( 'minute' , 1 ) , array ( 'minutes' , round ( $ minutes ) ) , array ( 'hour' , 1 ) , array ( 'hours' , round ( $ hours ) ) , array ( 'day' , 1 ) , array ( 'days' , round ( $ days ) ) , array ( 'month' , 1 ) , array ( 'months' , round ( $ days / 30 ) ) , array ( 'year' , 1 ) , array ( 'years' , round ( $ years ) ) ) ; for ( $ i = 0 ; $ i < $ count = count ( $ wordsConds ) ; ++ $ i ) { if ( $ wordsConds [ $ i ] ) { $ key = $ wordResults [ $ i ] [ 0 ] ; $ number = $ wordResults [ $ i ] [ 1 ] ; if ( is_array ( $ this -> data [ $ key ] ) && is_callable ( $ this -> data [ 'rules' ] ) ) { $ n = call_user_func ( $ this -> data [ 'rules' ] , $ wordResults [ $ i ] [ 1 ] ) ; $ message = $ this -> data [ $ key ] [ $ n ] ; } else { $ message = $ this -> data [ $ key ] ; } return trim ( implode ( $ separator , array ( $ prefix , preg_replace ( '/%d/i' , $ number , $ message ) , $ suffix ) ) ) ; } } }
Converts time delta to timeago formatted string

@param integer $seconds time delta in seconds

@return string timeago formatted string
Converts time delta to timeago formatted string