public static function elapsedString($timestamp, $hide_empty = true, $to = 0, $separator = ', ')
{
// If no $to then now
if (empty($to)) {
$to = time();
}
// Key and string output
$useful = array('y' => array(__('Year'), __('Years')), 'm' => array(__('Month'), __('Months')), 'd' => array(__('Day'), __('Days')), 'h' => array(__('Hour'), __('Hours')), 'i' => array(__('Minute'), __('Minutes')), 's' => array(__('Second'), __('Seconds')));
$matrix = array('y' => array(12 * 30 * 24 * 60 * 60, 12), 'm' => array(30 * 24 * 60 * 60, 30), 'd' => array(24 * 60 * 60, 24), 'h' => array(60 * 60, 60), 'i' => array(60, 60), 's' => array(1, 60));
$diff = $timestamp - $to;
$stack = array();
foreach ($useful as $w => $strings) {
$value = floor($diff / $matrix[$w][0]) % $matrix[$w][1];
if (empty($value) || $value < 0) {
if ($hide_empty) {
continue;
}
$value = 0;
}
$stack[] = sprintf('%s %s', $value, _n($strings[0], $strings[1], $value));
}
return implode($separator, $stack);
}