public static function howLongAgo(int $secs): string
    {
        static $timeFormats = [
            [0, '< 1 sec'],
            [1, '1 sec'],
            [2, 'secs', 1],
            [60, '1 min'],
            [120, 'mins', 60],
            [3600, '1 hr'],
            [7200, 'hrs', 3600],
            [86400, '1 day'],
            [172800, 'days', 86400],
        ];

        foreach ($timeFormats as $index => $format) {
            if ($secs >= $format[0]) {
                $next = $timeFormats[$index + 1] ?? false;

                if (($next && $secs < $next[0]) || $index === \count($timeFormats) - 1) {
                    if (2 === \count($format)) {
                        return $format[1];
                    }

                    return \floor($secs / $format[2]) . ' ' . $format[1];
                }
            }
        }

        return \date('Y-m-d H:i:s', $secs);
    }
public static function howLongAgo(int $secs): string
    {
        static $timeFormats = [
            [0, '< 1 sec'],
            [1, '1 sec'],
            [2, 'secs', 1],
            [60, '1 min'],
            [120, 'mins', 60],
            [3600, '1 hr'],
            [7200, 'hrs', 3600],
            [86400, '1 day'],
            [172800, 'days', 86400],
        ];

        foreach ($timeFormats as $index => $format) {
            if ($secs >= $format[0]) {
                $next = $timeFormats[$index + 1] ?? false;

                if (($next && $secs < $next[0]) || $index === \count($timeFormats) - 1) {
                    if (2 === \count($format)) {
                        return $format[1];
                    }

                    return \floor($secs / $format[2]) . ' ' . $format[1];
                }
            }
        }

        return \date('Y-m-d H:i:s', $secs);
    }
public static function howLongAgo ( int $ secs ) : string { static $ timeFormats = [ [ 0 , '< 1 sec' ] , [ 1 , '1 sec' ] , [ 2 , 'secs' , 1 ] , [ 60 , '1 min' ] , [ 120 , 'mins' , 60 ] , [ 3600 , '1 hr' ] , [ 7200 , 'hrs' , 3600 ] , [ 86400 , '1 day' ] , [ 172800 , 'days' , 86400 ] , ] ; foreach ( $ timeFormats as $ index => $ format ) { if ( $ secs >= $ format [ 0 ] ) { $ next = $ timeFormats [ $ index + 1 ] ?? false ; if ( ( $ next && $ secs < $ next [ 0 ] ) || $ index === \ count ( $ timeFormats ) - 1 ) { if ( 2 === \ count ( $ format ) ) { return $ format [ 1 ] ; } return \ floor ( $ secs / $ format [ 2 ] ) . ' ' . $ format [ 1 ] ; } } } return \ date ( 'Y-m-d H:i:s' , $ secs ) ; }
format timestamp to how long ago
@param  int $secs
@return string
format timestamp to how long ago