protected function ago()
    {
        $threshold = $this->getParameter('threshold');

        if (($this->getParameter('value') == null || $this->getParameter('value') == "0"))
            return '';
        elseif (($this->getParameter('value') != null) && $this->getParameter('value') instanceof Meta) {
            $dateTime = $this->getParameter('value');
            $dateTime = $dateTime->MetaValue;
        } elseif (($this->getParameter('value') != null) && $this->getParameter('value') instanceof Date)
            $dateTime = $this->getParameter('value');
        elseif (($this->getParameter('value') == null) || $this->getParameter('value') == 'now')
            $dateTime = $this->DateFactory->newLocalDate('@'.time());
        else{

            try {

                $dateTime = $this->DateFactory->newLocalDate($this->getParameter('value'));

            }catch(DateException $e)
            {
                return '';
            }

        }

        $datetime = $this->DateFactory->toLocalDate($dateTime);

        $now = time();

        if($now >= $datetime->toUnix())
        {
            $ago = $now - $datetime->toUnix();
        } else {
            $ago = $datetime->toUnix() - $now;
        }

        if($threshold != null && $ago > (intval($threshold)*60)) {
            return $this->format();
        }

        $text = '';
            if ($ago < 60)
                $text .= 'less than a minute';
            elseif ($ago < 120)
                $text .= 'about a minute';
            elseif ($ago < (60*60))
                $text .= ceil($ago/60) . ' minutes';
            elseif ($ago < (120*60))
                $text .= 'about an hour';
            elseif ($ago < (24*60*60))
                $text .= ceil($ago/(60*60)) . ' hours';
            elseif ($ago < (48*60*60))
                $text .= '1 day';
            else
                $text .= ceil($ago / (24*60*60)).' days';

        if($now >= $datetime->toUnix())
        {
            $text .= ' ago';
        } else {
            $text .= ' from now';
        }

        return $text;
    }
protected function ago()
    {
        $threshold = $this->getParameter('threshold');

        if (($this->getParameter('value') == null || $this->getParameter('value') == "0"))
            return '';
        elseif (($this->getParameter('value') != null) && $this->getParameter('value') instanceof Meta) {
            $dateTime = $this->getParameter('value');
            $dateTime = $dateTime->MetaValue;
        } elseif (($this->getParameter('value') != null) && $this->getParameter('value') instanceof Date)
            $dateTime = $this->getParameter('value');
        elseif (($this->getParameter('value') == null) || $this->getParameter('value') == 'now')
            $dateTime = $this->DateFactory->newLocalDate('@'.time());
        else{

            try {

                $dateTime = $this->DateFactory->newLocalDate($this->getParameter('value'));

            }catch(DateException $e)
            {
                return '';
            }

        }

        $datetime = $this->DateFactory->toLocalDate($dateTime);

        $now = time();

        if($now >= $datetime->toUnix())
        {
            $ago = $now - $datetime->toUnix();
        } else {
            $ago = $datetime->toUnix() - $now;
        }

        if($threshold != null && $ago > (intval($threshold)*60)) {
            return $this->format();
        }

        $text = '';
            if ($ago < 60)
                $text .= 'less than a minute';
            elseif ($ago < 120)
                $text .= 'about a minute';
            elseif ($ago < (60*60))
                $text .= ceil($ago/60) . ' minutes';
            elseif ($ago < (120*60))
                $text .= 'about an hour';
            elseif ($ago < (24*60*60))
                $text .= ceil($ago/(60*60)) . ' hours';
            elseif ($ago < (48*60*60))
                $text .= '1 day';
            else
                $text .= ceil($ago / (24*60*60)).' days';

        if($now >= $datetime->toUnix())
        {
            $text .= ' ago';
        } else {
            $text .= ' from now';
        }

        return $text;
    }
protected function ago ( ) { $ threshold = $ this -> getParameter ( 'threshold' ) ; if ( ( $ this -> getParameter ( 'value' ) == null || $ this -> getParameter ( 'value' ) == "0" ) ) return '' ; elseif ( ( $ this -> getParameter ( 'value' ) != null ) && $ this -> getParameter ( 'value' ) instanceof Meta ) { $ dateTime = $ this -> getParameter ( 'value' ) ; $ dateTime = $ dateTime -> MetaValue ; } elseif ( ( $ this -> getParameter ( 'value' ) != null ) && $ this -> getParameter ( 'value' ) instanceof Date ) $ dateTime = $ this -> getParameter ( 'value' ) ; elseif ( ( $ this -> getParameter ( 'value' ) == null ) || $ this -> getParameter ( 'value' ) == 'now' ) $ dateTime = $ this -> DateFactory -> newLocalDate ( '@' . time ( ) ) ; else { try { $ dateTime = $ this -> DateFactory -> newLocalDate ( $ this -> getParameter ( 'value' ) ) ; } catch ( DateException $ e ) { return '' ; } } $ datetime = $ this -> DateFactory -> toLocalDate ( $ dateTime ) ; $ now = time ( ) ; if ( $ now >= $ datetime -> toUnix ( ) ) { $ ago = $ now - $ datetime -> toUnix ( ) ; } else { $ ago = $ datetime -> toUnix ( ) - $ now ; } if ( $ threshold != null && $ ago > ( intval ( $ threshold ) * 60 ) ) { return $ this -> format ( ) ; } $ text = '' ; if ( $ ago < 60 ) $ text .= 'less than a minute' ; elseif ( $ ago < 120 ) $ text .= 'about a minute' ; elseif ( $ ago < ( 60 * 60 ) ) $ text .= ceil ( $ ago / 60 ) . ' minutes' ; elseif ( $ ago < ( 120 * 60 ) ) $ text .= 'about an hour' ; elseif ( $ ago < ( 24 * 60 * 60 ) ) $ text .= ceil ( $ ago / ( 60 * 60 ) ) . ' hours' ; elseif ( $ ago < ( 48 * 60 * 60 ) ) $ text .= '1 day' ; else $ text .= ceil ( $ ago / ( 24 * 60 * 60 ) ) . ' days' ; if ( $ now >= $ datetime -> toUnix ( ) ) { $ text .= ' ago' ; } else { $ text .= ' from now' ; } return $ text ; }
Displays a short text description of how long ago the specified timestamp was current.

Expected Params:
value     LocalDate (optional) If specified and 'strdate' is null, use this as the timestamp
strdate   string    (optional) A string to use to create the timestamp
threshold integer   (optional) If the value is older than now - threshold (in minutes), display the timestamp using format
format    string    (optional) The format for the date to use

@return string
Displays a short text description of how long ago the specified timestamp was current .