Tools.php
public static function getRelativeTime($value)
    {
        //Make sure we have timestamp
        if (!\is_int($value)) {
            $value = strtotime($value);
        }

        $diff = abs($value - time());
        if ($value < time()) {
            if ($diff < 60) {
                //Less than a minute
                return self::poorManTranslate('fts-shared', 'a few seconds ago');
            }

            if ($diff < 3600) {
                //Less than a hour
                return self::poorManTranslate('fts-shared', 'a {n, plural, =1{minute} other{# minutes}} ago', ['n' => floor($diff / 60)]);
            }

            if ($diff < 86400) {
                //Less than a day
                return self::poorManTranslate('fts-shared', 'a {n, plural, =1{hour} other{# hours}} ago', ['n' => floor($diff / 3600)]);
            }

            if ($diff < 172800) {
                //Less than two days
                return self::poorManTranslate('fts-shared', 'yesterday');
            }

            if ($diff < 604800) {
                //Less than a week
                return self::poorManTranslate('fts-shared', 'a {n} days ago', ['n' => floor($diff / 86400)]);
            }

            if ($diff < 2628000) {
                //Less than a month
                return self::poorManTranslate('fts-shared', 'a {n, plural, =1{week} other{# weeks}} ago', ['n' => floor($diff / 604800)]);
            }

            if ($diff < 31556926) {
                //Less than a year
                return self::poorManTranslate('fts-shared', 'a {n, plural, =1{month} other{# months}} ago', ['n' => floor($diff / 2628000)]);
            }

            //Less than eternity :-)
            return self::poorManTranslate('fts-shared', 'a {n, plural, =1{year} other{# years}} ago', ['n' => floor($diff / 31556926)]);
        }

        if ($diff < 60) {
            //Less than a minute
            return self::poorManTranslate('fts-shared', 'after a few seconds');
        }

        if ($diff < 3600) {
            //Less than a hour
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{minute} other{# minutes}}', ['n' => floor($diff / 60)]);
        }

        if ($diff < 86400) {
            //Less than a day
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{hour} other{# hours}}', ['n' => floor($diff / 3600)]);
        }

        if ($diff < 172800) {
            //Less than two days
            return self::poorManTranslate('fts-shared', 'tomorrow');
        }

        if ($diff < 604800) {
            //Less than a week
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{day} other{# days}}', ['n' => floor($diff / 86400)]);
        }

        if ($diff < 2628000) {
            //Less than a month
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{week} other{# weeks}}', ['n' => floor($diff / 604800)]);
        }

        if ($diff < 31556926) {
            //Less than a year
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{month} other{# months}}', ['n' => floor($diff / 2628000)]);
        }

        //Less than eternity :-)
        return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{year} other{# years}}', ['n' => floor($diff / 31556926)]);
    }
public static function getRelativeTime($value)
    {
        //Make sure we have timestamp
        if (!\is_int($value)) {
            $value = strtotime($value);
        }

        $diff = abs($value - time());
        if ($value < time()) {
            if ($diff < 60) {
                //Less than a minute
                return self::poorManTranslate('fts-shared', 'a few seconds ago');
            }

            if ($diff < 3600) {
                //Less than a hour
                return self::poorManTranslate('fts-shared', 'a {n, plural, =1{minute} other{# minutes}} ago', ['n' => floor($diff / 60)]);
            }

            if ($diff < 86400) {
                //Less than a day
                return self::poorManTranslate('fts-shared', 'a {n, plural, =1{hour} other{# hours}} ago', ['n' => floor($diff / 3600)]);
            }

            if ($diff < 172800) {
                //Less than two days
                return self::poorManTranslate('fts-shared', 'yesterday');
            }

            if ($diff < 604800) {
                //Less than a week
                return self::poorManTranslate('fts-shared', 'a {n} days ago', ['n' => floor($diff / 86400)]);
            }

            if ($diff < 2628000) {
                //Less than a month
                return self::poorManTranslate('fts-shared', 'a {n, plural, =1{week} other{# weeks}} ago', ['n' => floor($diff / 604800)]);
            }

            if ($diff < 31556926) {
                //Less than a year
                return self::poorManTranslate('fts-shared', 'a {n, plural, =1{month} other{# months}} ago', ['n' => floor($diff / 2628000)]);
            }

            //Less than eternity :-)
            return self::poorManTranslate('fts-shared', 'a {n, plural, =1{year} other{# years}} ago', ['n' => floor($diff / 31556926)]);
        }

        if ($diff < 60) {
            //Less than a minute
            return self::poorManTranslate('fts-shared', 'after a few seconds');
        }

        if ($diff < 3600) {
            //Less than a hour
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{minute} other{# minutes}}', ['n' => floor($diff / 60)]);
        }

        if ($diff < 86400) {
            //Less than a day
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{hour} other{# hours}}', ['n' => floor($diff / 3600)]);
        }

        if ($diff < 172800) {
            //Less than two days
            return self::poorManTranslate('fts-shared', 'tomorrow');
        }

        if ($diff < 604800) {
            //Less than a week
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{day} other{# days}}', ['n' => floor($diff / 86400)]);
        }

        if ($diff < 2628000) {
            //Less than a month
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{week} other{# weeks}}', ['n' => floor($diff / 604800)]);
        }

        if ($diff < 31556926) {
            //Less than a year
            return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{month} other{# months}}', ['n' => floor($diff / 2628000)]);
        }

        //Less than eternity :-)
        return self::poorManTranslate('fts-shared', 'after a {n, plural, =1{year} other{# years}}', ['n' => floor($diff / 31556926)]);
    }
Get textual representation of time difference in style 'some time ago'

@param int|string $value Time in any format accepted by strtotime()

@return string Textual representation of time difference
@static