function TimeSpent($sec) { $month = (int) ($sec / 2628000); $days = (int) ($sec / 86400) % 30; $hours = (int) ($sec / 3600) % 24; $minuts = (int) (($sec / 60) % 60); $seconds = $sec % 60; ); $result = ''; foreach ($time_arr as $time) { if ($time[0] > 0) { $result .= $time[0] . ' ' . $time[1] . ' '; } } return trim(str_replace(array('мес д', 'д ч', 'ч м', 'м с'), array('мес ', 'д ', 'ч ', 'м '), $result)); }