concrete/src/Localization/Service/Date.php
public function describeInterval($diff, $precise = false)
    {
        $secondsPerMinute = 60;
        $secondsPerHour = 60 * $secondsPerMinute;
        $secondsPerDay = 24 * $secondsPerHour;
        $days = floor($diff / $secondsPerDay);
        $diff = $diff - $days * $secondsPerDay;
        $hours = floor($diff / $secondsPerHour);
        $diff = $diff - $hours * $secondsPerHour;
        $minutes = floor($diff / $secondsPerMinute);
        $seconds = $diff - $minutes * $secondsPerMinute;
        $chunks = [];
        if ($days > 0) {
            $chunks[] = t2('%d day', '%d days', $days, $days);
            if ($precise) {
                $chunks[] = t2('%d hour', '%d hours', $hours, $hours);
            }
        } elseif ($hours > 0) {
            $chunks[] = t2('%d hour', '%d hours', $hours, $hours);
            if ($precise) {
                $chunks[] = t2('%d minute', '%d minutes', $minutes, $minutes);
            }
        } elseif ($minutes > 0) {
            $chunks[] = t2('%d minute', '%d minutes', $minutes, $minutes);
            if ($precise) {
                $chunks[] = t2('%d second', '%d seconds', $seconds, $seconds);
            }
        } else {
            $chunks[] = t2('%d second', '%d seconds', $seconds, $seconds);
        }

        return Misc::join($chunks);
    }
public function describeInterval($diff, $precise = false)
    {
        $secondsPerMinute = 60;
        $secondsPerHour = 60 * $secondsPerMinute;
        $secondsPerDay = 24 * $secondsPerHour;
        $days = floor($diff / $secondsPerDay);
        $diff = $diff - $days * $secondsPerDay;
        $hours = floor($diff / $secondsPerHour);
        $diff = $diff - $hours * $secondsPerHour;
        $minutes = floor($diff / $secondsPerMinute);
        $seconds = $diff - $minutes * $secondsPerMinute;
        $chunks = [];
        if ($days > 0) {
            $chunks[] = t2('%d day', '%d days', $days, $days);
            if ($precise) {
                $chunks[] = t2('%d hour', '%d hours', $hours, $hours);
            }
        } elseif ($hours > 0) {
            $chunks[] = t2('%d hour', '%d hours', $hours, $hours);
            if ($precise) {
                $chunks[] = t2('%d minute', '%d minutes', $minutes, $minutes);
            }
        } elseif ($minutes > 0) {
            $chunks[] = t2('%d minute', '%d minutes', $minutes, $minutes);
            if ($precise) {
                $chunks[] = t2('%d second', '%d seconds', $seconds, $seconds);
            }
        } else {
            $chunks[] = t2('%d second', '%d seconds', $seconds, $seconds);
        }

        return Misc::join($chunks);
    }
public function describeInterval ( $ diff , $ precise = false ) { $ secondsPerMinute = 60 ; $ secondsPerHour = 60 * $ secondsPerMinute ; $ secondsPerDay = 24 * $ secondsPerHour ; $ days = floor ( $ diff / $ secondsPerDay ) ; $ diff = $ diff - $ days * $ secondsPerDay ; $ hours = floor ( $ diff / $ secondsPerHour ) ; $ diff = $ diff - $ hours * $ secondsPerHour ; $ minutes = floor ( $ diff / $ secondsPerMinute ) ; $ seconds = $ diff - $ minutes * $ secondsPerMinute ; $ chunks = [ ] ; if ( $ days > 0 ) { $ chunks [ ] = t2 ( '%d day' , '%d days' , $ days , $ days ) ; if ( $ precise ) { $ chunks [ ] = t2 ( '%d hour' , '%d hours' , $ hours , $ hours ) ; } } elseif ( $ hours > 0 ) { $ chunks [ ] = t2 ( '%d hour' , '%d hours' , $ hours , $ hours ) ; if ( $ precise ) { $ chunks [ ] = t2 ( '%d minute' , '%d minutes' , $ minutes , $ minutes ) ; } } elseif ( $ minutes > 0 ) { $ chunks [ ] = t2 ( '%d minute' , '%d minutes' , $ minutes , $ minutes ) ; if ( $ precise ) { $ chunks [ ] = t2 ( '%d second' , '%d seconds' , $ seconds , $ seconds ) ; } } else { $ chunks [ ] = t2 ( '%d second' , '%d seconds' , $ seconds , $ seconds ) ; } return Misc :: join ( $ chunks ) ; }
Returns the localized representation of a time interval specified as seconds.

@param int $diff The time difference in seconds
@param bool $precise = false Set to true to a more verbose and precise result, false for a more rounded result

@return string
Returns the localized representation of a time interval specified as seconds .