Like distance_of_time_in_words, but where to_time is fixed to timestamp()

@param $from_time String or DateTime
@param bool $include_seconds
@param bool $include_months

@return mixed
3397
function timeAgoInWords($from_time, $include_seconds = false, $include_months = false)
    {
        return $this->distanceOfTimeInWordsFilter($from_time, new \DateTime('now'), $include_seconds, $include_months);
    }
21874
private function relativePath($from, $to, $ps = DIRECTORY_SEPARATOR)
    {
        $from = realpath($from);
        $to = realpath($to);

        $equalOffset = 0;
        $minLength = min(strlen($from), strlen($to));

        while ($equalOffset < $minLength && $from[$equalOffset] == $to[$equalOffset]) {
            $equalOffset++;
        }

        $backCount = $equalOffset == $minLength && strlen($from) < strlen($to) ?
            0 : substr_count($from, $ps, $equalOffset-1);

        return rtrim(str_repeat('..'.$ps, $backCount).ltrim(substr($to, $equalOffset), $ps), $ps);
    }
1351100
public static function getOffsetBySeconds($seconds)
    {
        $tmp    = abs($seconds);
        $hour   = (int) ($tmp / 3600);
        $minute = (int) (($tmp % 3600) / 60);

        $result = $seconds < 0 ? '-' : '+';
        $result.= ($hour < 10  ? '0' . $hour   : $hour) . ':';
        $result.= $minute < 10 ? '0' . $minute : $minute;

        return $result;
    }
1124170
public function dateDiff($time1, $time2 = null)
    {
        if (is_null($time2)) {
            $time2 = Mage::getModel('core/date')->date();
        }
        $time1 = strtotime($time1);
        $time2 = strtotime($time2);
        return $time2 - $time1;
    }
700751
public static function relativeTime($time, array $options = array()) {
        $g11n = G11n::registry();
        $msg = function($key) use ($g11n) {
            return $g11n->translate('core.format.relativeTime.' . $key);
        };

        // TODO Find a more optimized way to do this.
        $options = $options + array(
            'seconds' => array($msg('sec'), $msg('second'), $msg('seconds')),
            'minutes' => array($msg('min'), $msg('minute'), $msg('minutes')),
            'hours' => array($msg('hr'), $msg('hour'), $msg('hours')),
            'days' => array($msg('dy'), $msg('day'), $msg('days')),
            'weeks' => array($msg('wk'), $msg('week'), $msg('weeks')),
            'months' => array($msg('mon'), $msg('month'), $msg('months')),
            'years' => array($msg('yr'), $msg('year'), $msg('years')),
            'now' => $msg('now'),
            'in' => $msg('in'),
            'ago' => $msg('ago')
        );

        return parent::relativeTime($time, $options);
    }
621307
public function setDateInclude($include, $field = null)
    {
        $param = $this->buildParam('facet.date.include', $field);
        return $this->set($param, $include);
    }
618283
public function bySeconds(int $seconds): Date
    {
        return $this->secondTo($this->originalDate->seconds() + $seconds);
    }
891592
@Override
    public boolean isTimeIncluded(long timeStamp) {
        Date lookFor = getStartOfDayJavaCalendar(timeStamp).getTime();
        boolean include=workdays.contains(lookFor);
        return include;
    }
1082618
public static function to_timezone(string $date, $from='UTC', $to='UTC') {
		ref\format::to_timezone($date, $from, $to);
		return $date;
	}
292237
public static function relativeTime($time, array $options = array()) {
        $defaults = array(
            'seconds' => array('%ss', '%s second', '%s seconds'),
            'minutes' => array('%sm', '%s minute', '%s minutes'),
            'hours' => array('%sh', '%s hour', '%s hours'),
            'days' => array('%sd', '%s day', '%s days'),
            'weeks' => array('%sw', '%s week', '%s weeks'),
            'months' => array('%sm', '%s month', '%s months'),
            'years' => array('%sy', '%s year', '%s years'),
            'now' => 'just now',
            'in' => 'in %s',
            'ago' => '%s ago',
            'separator' => ', ',
            'verbose' => true,
            'depth' => 2,
            'time' => time()
        );

        $options = $options + $defaults;
        $diff = Time::difference($options['time'], Time::toUnix($time));
        $output = array();

        // Present tense
        if ($diff === 0) {
            return $options['now'];
        }

        // Past or future tense
        $seconds = abs($diff);
        $depth = $options['depth'];

        while ($seconds > 0 && $depth > 0) {
            if ($seconds >= Time::YEAR) {
                $key = 'years';
                $div = Time::YEAR;

            } else if ($seconds >= Time::MONTH) {
                $key = 'months';
                $div = Time::MONTH;

            } else if ($seconds >= Time::WEEK) {
                $key = 'weeks';
                $div = Time::WEEK;

            } else if ($seconds >= Time::DAY) {
                $key = 'days';
                $div = Time::DAY;

            } else if ($seconds >= Time::HOUR) {
                $key = 'hours';
                $div = Time::HOUR;

            } else if ($seconds >= Time::MINUTE) {
                $key = 'minutes';
                $div = Time::MINUTE;

            } else {
                $key = 'seconds';
                $div = Time::SECOND;
            }

            $count = round($seconds / $div);
            $seconds -= ($count * $div);

            if ($options['verbose']) {
                $index = ($count == 1) ? 1 : 2;
            } else {
                $index = 0;
            }

            $output[$key] = sprintf($options[$key][$index], $count);
            $depth--;
        }

        $output = implode($options['separator'], $output);

        // Past
        if ($diff > 0) {
            return sprintf($options['ago'], $output);
        }

        return sprintf($options['in'], $output);
    }
807711
def relative_time_ago(from_time, to_time)
      distance_in_minutes = (((from_time.to_time - to_time.to_time).abs)/60).round
      case distance_in_minutes
      when 0..1 then 'about a minute'
      when 2..44 then "#{distance_in_minutes} minutes"
      when 45..89 then 'about 1 hour'
      when 90..1439 then "about #{(distance_in_minutes.to_f / 60.0).round} hours"
      when 1440..2439 then '1 day'
      when 2440..2879 then 'about 2 days'
      when 2880..43199 then "#{(distance_in_minutes / 1440).round} days"
      when 43200..86399 then 'about 1 month'
      when 86400..525599 then "#{(distance_in_minutes / 43200).round} months"
      when 525600..1051199 then 'about 1 year'
      else "over #{(distance_in_minutes / 525600).round} years"
      end
    end
1299914
public static function generateDateIndices($format, $interval, $from_ts, $to_ts) {
        $fmt_arr = [];
        $escaped = false;

        foreach(str_split($format) as $chr) {
            switch($chr) {
            case '[':
                $escaped = true;
                break;
            case ']':
                $escaped = false;
                break;
            default:
                $fmt_arr[] = $escaped ? "\\$chr":$chr;
                break;
            }
        }
        $fmt_str = implode('', $fmt_arr);

        $ret = [];
        $current = new \DateTime("@$from_ts");
        $to = new \DateTime("@$to_ts");

        $interval_map = [
            'y' => 'year',
            'm' => 'month',
            'w' => 'week',
            'd' => 'day',
            'h' => 'hour',
        ];
        $interval_str = Util::get($interval_map, $interval, 'day');

        // Zero out the time component.
        $current->setTime($interval == 'h' ? $current->format('H'):0, 0);

        while ($current <= $to) {
            $ret[] = $current->format($fmt_str);
            $current = $current->modify("+1$interval_str");
        }

        return $ret;
    }
72196
public function setTimeRange($from, $to)
    {
        $fromDate = date('Y-m-d H:i:s', (int) $from);
        $toDate = date('Y-m-d H:i:s', (int) $to);

        $this->where(array("time > '$fromDate'", "time < '$toDate'"));

        return $this;
    }
144355
private function retrieveIntervalFromSeconds($seconds)
    {
        $result = '';
        $remainingTime = (int) $seconds;

        if (empty($remainingTime)) {
            $result .= 'PT0S';
        } else {
            $nbDays = (int) ($remainingTime / 86400);
            $remainingTime %= 86400;
            $nbHours = (int) ($remainingTime / 3600);
            $remainingTime %= 3600;
            $nbMinutes = (int) ($remainingTime / 60);
            $nbSeconds = $remainingTime % 60;
            $result .= 'P'.$nbDays.'DT'.$nbHours.'H'.$nbMinutes.'M'.$nbSeconds.'S';
        }

        return $result;
    }
235506
public static function time_ago($timestamp, $from_timestamp = null, $unit = null)
	{
		if ($timestamp === null)
		{
			return '';
		}

		! is_numeric($timestamp) and $timestamp = static::create_from_string($timestamp)->get_timestamp();

		$from_timestamp == null and $from_timestamp = time();

		\Lang::load('date', true);

		$difference = $from_timestamp - $timestamp;
		$periods    = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade');
		$lengths    = array(60, 60, 24, 7, 4.35, 12, 10);

		for ($j = 0; isset($lengths[$j]) and $difference >= $lengths[$j] and (empty($unit) or $unit != $periods[$j]); $j++)
		{
			$difference /= $lengths[$j];
		}

        $difference = round($difference);

		if ($difference != 1)
		{
			$periods[$j] = \Inflector::pluralize($periods[$j]);
		}

		$text = \Lang::get('date.text', array(
			'time' => \Lang::get('date.'.$periods[$j], array('t' => $difference))
		));

		return $text;
	}
1241087
public static function timeDiffSeconds(DateTime $time1, DateTime $time2)
    {
        $interval = $time1->diff($time2);

        return self::totalSeconds($interval);
    }
525912
def distance_of_time_in_words(from_time, to_time = Time.now) # rubocop:disable CyclomaticComplexity
      seconds = (to_time - from_time).abs
      minutes = seconds / 60
      case minutes
      when 0...1
        case seconds
        when 0...1
          'a split second'
        when 1...2
          'a second'
        when 2...60
          format('%d seconds', seconds)
        end
      when 1...2
        'a minute'
      when 2...60
        format('%d minutes', minutes)
      when 60...120
        'an hour'
      # 120 minutes up to 23.5 hours
      when 120...1410
        format('%d hours', (minutes.to_f / 60.0).round)
      # 23.5 hours up to 48 hours
      when 1410...2880
        'a day'
      # 48 hours up to 29.5 days
      when 2880...42_480
        format('%d days', (minutes.to_f / 1440.0).round)
      # 29.5 days up to 60 days
      when 42_480...86_400
        'a month'
      # 60 days up to 11.5 months
      when 86_400...503_700
        format('%d months', (minutes.to_f / 43_800.0).round)
      # 11.5 months up to 2 years
      when 503_700...1_051_200
        'a year'
      else
        format('%d years', (minutes.to_f / 525_600.0).round)
      end
    end