function myTime($hour, $minute) {
$resulth = ($hour <= 10) ? $hour % 10 : $hour % 20;
switch ($resulth) {
case 1:
echo "$hour час";
break;
case 2:
case 3:
case 4:
echo "$hour часа";
break;
default:
echo "$hour часов";
break;
}
$resultm = ($minute <= 10) ? $minute % 10 : $minute % 20;
switch ($resultm) {
case 1:
return "$minute минута";
case 2:
case 3:
case 4:
return "$minute минуты";
default:
return "$minute минут";
}
}
$hour = rand(0, 24);
$minute = rand(0, 59);
echo myTime($hour, $minute);
function word_variation_rus($chislo, $mnogo, $odin, $dva) {
// @author Alexey Gnevyshev
$ost_10 = $chislo%10;
if ($ost_10 == 0 || $ost_10 >= 5 || in_array($chislo%100, range(11,19))) $string_txt = "$chislo $mnogo";
else {
if ($ost_10 == 1) $string_txt = "$chislo $odin";
else if (in_array($ost_10, range(2,4))) $string_txt = "$chislo $dva";
}
return $string_txt;
}
echo word_variation_rus($minute, 'минут', 'минута', 'минуты');