Timber\Twig::time_ago PHP Метод

time_ago() публичный Метод

public time_ago ( integer | string $from, integer | string $to = null, string $format_past = '%s ago', string $format_future = '%s from now' ) : string
$from integer | string
$to integer | string
$format_past string
$format_future string
Результат string
    public function time_ago($from, $to = null, $format_past = '%s ago', $format_future = '%s from now')
    {
        $to = $to === null ? time() : $to;
        $to = is_int($to) ? $to : strtotime($to);
        $from = is_int($from) ? $from : strtotime($from);
        if ($from < $to) {
            return sprintf($format_past, human_time_diff($from, $to));
        } else {
            return sprintf($format_future, human_time_diff($to, $from));
        }
    }