kernel/lib/Date.php
public static function getTimeAgoInString(string $sDateTime, string $sLanguage = 'fr') : string
    {
        if ($sLanguage == 'fr') {

            $sStartReturn = 'Il y a';
            $sEndReturn = '';
            $sMinutes = 'minute(s) ';
            $sHours = 'heure(s) ';
            $sDays = 'jour(s) ';
            $sMonths = 'mois ';
            $sYears = 'années ';
        } else {
            $sStartReturn = 'Ago';
            $sEndReturn = '';
            $sMinutes = 'minute(s) ';
            $sHours = 'hour(s) ';
            $sDays = 'day(s) ';
            $sMonths = 'month ';
            $sYears = 'years ';
        }

        $oDateTime = DateTime::createFromFormat('Y-m-d H:i:s', $sDateTime);
        $iTimeStamp = time() - $oDateTime->getTimestamp();

        if ($iTimeStamp < 3600) { return $sStartReturn.' '.(int)($iTimeStamp/60).' '.$sMinutes.$sEndReturn; }
        if ($iTimeStamp < 86400) { return $sStartReturn.' '.(int)($iTimeStamp/3600).' '.$sHours.$sEndReturn; }
        if ($iTimeStamp < 2592000) { return $sStartReturn.' '.(int)($iTimeStamp/86400).' '.$sDays.$sEndReturn; }
        if ($iTimeStamp < 31536000) { return $sStartReturn.' '.(int)($iTimeStamp/2592000).' '.$sMonths.$sEndReturn; }
        else { return $sStartReturn.' '.(int)($iTimeStamp/31536000).' '.$sYears.$sEndReturn; }
    }
public static function getTimeAgoInString(string $sDateTime, string $sLanguage = 'fr') : string
    {
        if ($sLanguage == 'fr') {

            $sStartReturn = 'Il y a';
            $sEndReturn = '';
            $sMinutes = 'minute(s) ';
            $sHours = 'heure(s) ';
            $sDays = 'jour(s) ';
            $sMonths = 'mois ';
            $sYears = 'années ';
        } else {
            $sStartReturn = 'Ago';
            $sEndReturn = '';
            $sMinutes = 'minute(s) ';
            $sHours = 'hour(s) ';
            $sDays = 'day(s) ';
            $sMonths = 'month ';
            $sYears = 'years ';
        }

        $oDateTime = DateTime::createFromFormat('Y-m-d H:i:s', $sDateTime);
        $iTimeStamp = time() - $oDateTime->getTimestamp();

        if ($iTimeStamp < 3600) { return $sStartReturn.' '.(int)($iTimeStamp/60).' '.$sMinutes.$sEndReturn; }
        if ($iTimeStamp < 86400) { return $sStartReturn.' '.(int)($iTimeStamp/3600).' '.$sHours.$sEndReturn; }
        if ($iTimeStamp < 2592000) { return $sStartReturn.' '.(int)($iTimeStamp/86400).' '.$sDays.$sEndReturn; }
        if ($iTimeStamp < 31536000) { return $sStartReturn.' '.(int)($iTimeStamp/2592000).' '.$sMonths.$sEndReturn; }
        else { return $sStartReturn.' '.(int)($iTimeStamp/31536000).' '.$sYears.$sEndReturn; }
    }
get time of kind "X hour ago"

@access public
@param  string $sDateTime datetime to convert
@param  string $sLanguage language
@return string