yunasc/tbdev — pull request #17 by EdisonLV (2014-04-16 14:38:50+00:00)
Title: Lets count seconds aswell

function get_elapsed_time_plural($time_start, $decimals = 0) {
$divider['years'] = (60 * 60 * 24 * 365);
$divider['months'] = (60 * 60 * 24 * 365 / 12);
$divider['weeks'] = (60 * 60 * 24 * 7);
$divider['days'] = (60 * 60 * 24);
$divider['hours'] = (60 * 60);
$divider['minutes'] = (60);
$divider['seconds'] = (1);

$langs['years']	= array("год", "года", "лет");
$langs['months']	= array("месяц", "месяца", "месяцев");
$langs['weeks']	= array("неделю", "недели", "недель");
$langs['days']	= array("день", "дня", "дней");
$langs['hours']	= array("час", "часа", "часов");
$langs['minutes']	= array("минуту", "минуты", "минут");
$langs['seconds']	= array("секунду", "секунды", "секунд");

foreach ($divider as $unit => $div) {
${'elapsed_time_'.$unit} = floor(((TIMENOW - $time_start) / $div));
if (${'elapsed_time_'.$unit} >= 1)
break;
}
$elapsed_time = ${'elapsed_time_'.$unit} . ' ' . getWord(${'elapsed_time_'.$unit}, $langs[$unit]);

return $elapsed_time;
}