Templating/Helper/TimeFormatterHelper.php
private function formatNormal(\DateInterval $diff)
    {
        $str = '';
        $first = null;
        $second = null;
        $val = 0;

        if ($diff->y > 0) {
            $str = "year";
            $val = $diff->y;
        } else if ($diff->m > 0) {
            $str = "month";
            $val = $diff->m;
        } else if ($diff->d > 0) {
            $str = "day";
            $first = array('after' => "tomorrow", 'before' => "yesterday");
            $val = $diff->d;
        } else if ($diff->h > 0) {
            $str = "hour";
            $val = $diff->h;
        } else if ($diff->i == 30) {
            var_dump($diff->invert);
            return $diff->invert ? $this->translator->trans("next half hour") : $this->translator->trans("half hour ago");
        } else if ($diff->i > 0) {
            $str = "minute";
            $val = $diff->i;
        } else if ($diff->s > 0) {
            $str = "second";
            $val = $diff->s;
        }

        $id = "%" . $str . "s%";

        if ($diff->invert) {
            return $this->translator->transChoice(
                ($first && isset($first['after']) ? $first['after'] : "next " . $str) . "|" .
                ($second && isset($second['after']) ? $second['after'] : "next " . $id . " " . $str . "s"), $val, array(
                $id => $val
            ));
        } else {
            return $this->translator->transChoice(
                ($first && isset($first['before']) ? $first['before'] : ($str == "hour" ? 'an' : 'a') . ' ' . $str . ' ago') . "|" .
                ($second && isset($second['before']) ? $second['before'] : $id . " " . $str . "s ago"), $val, array(
                $id => $val
            ));
        }
    }
private function formatNormal(\DateInterval $diff)
    {
        $str = '';
        $first = null;
        $second = null;
        $val = 0;

        if ($diff->y > 0) {
            $str = "year";
            $val = $diff->y;
        } else if ($diff->m > 0) {
            $str = "month";
            $val = $diff->m;
        } else if ($diff->d > 0) {
            $str = "day";
            $first = array('after' => "tomorrow", 'before' => "yesterday");
            $val = $diff->d;
        } else if ($diff->h > 0) {
            $str = "hour";
            $val = $diff->h;
        } else if ($diff->i == 30) {
            var_dump($diff->invert);
            return $diff->invert ? $this->translator->trans("next half hour") : $this->translator->trans("half hour ago");
        } else if ($diff->i > 0) {
            $str = "minute";
            $val = $diff->i;
        } else if ($diff->s > 0) {
            $str = "second";
            $val = $diff->s;
        }

        $id = "%" . $str . "s%";

        if ($diff->invert) {
            return $this->translator->transChoice(
                ($first && isset($first['after']) ? $first['after'] : "next " . $str) . "|" .
                ($second && isset($second['after']) ? $second['after'] : "next " . $id . " " . $str . "s"), $val, array(
                $id => $val
            ));
        } else {
            return $this->translator->transChoice(
                ($first && isset($first['before']) ? $first['before'] : ($str == "hour" ? 'an' : 'a') . ' ' . $str . ' ago') . "|" .
                ($second && isset($second['before']) ? $second['before'] : $id . " " . $str . "s ago"), $val, array(
                $id => $val
            ));
        }
    }
private function formatNormal ( \ DateInterval $ diff ) { $ str = '' ; $ first = null ; $ second = null ; $ val = 0 ; if ( $ diff -> y > 0 ) { $ str = "year" ; $ val = $ diff -> y ; } else if ( $ diff -> m > 0 ) { $ str = "month" ; $ val = $ diff -> m ; } else if ( $ diff -> d > 0 ) { $ str = "day" ; $ first = array ( 'after' => "tomorrow" , 'before' => "yesterday" ) ; $ val = $ diff -> d ; } else if ( $ diff -> h > 0 ) { $ str = "hour" ; $ val = $ diff -> h ; } else if ( $ diff -> i == 30 ) { var_dump ( $ diff -> invert ) ; return $ diff -> invert ? $ this -> translator -> trans ( "next half hour" ) : $ this -> translator -> trans ( "half hour ago" ) ; } else if ( $ diff -> i > 0 ) { $ str = "minute" ; $ val = $ diff -> i ; } else if ( $ diff -> s > 0 ) { $ str = "second" ; $ val = $ diff -> s ; } $ id = "%" . $ str . "s%" ; if ( $ diff -> invert ) { return $ this -> translator -> transChoice ( ( $ first && isset ( $ first [ 'after' ] ) ? $ first [ 'after' ] : "next " . $ str ) . "|" . ( $ second && isset ( $ second [ 'after' ] ) ? $ second [ 'after' ] : "next " . $ id . " " . $ str . "s" ) , $ val , array ( $ id => $ val ) ) ; } else { return $ this -> translator -> transChoice ( ( $ first && isset ( $ first [ 'before' ] ) ? $ first [ 'before' ] : ( $ str == "hour" ? 'an' : 'a' ) . ' ' . $ str . ' ago' ) . "|" . ( $ second && isset ( $ second [ 'before' ] ) ? $ second [ 'before' ] : $ id . " " . $ str . "s ago" ) , $ val , array ( $ id => $ val ) ) ; } }
Formating using default format.

@param \DateInterval $diff

@return string
Formating using default format .