Файл: ka4ka/sys/func.php
Строк: 29
<?
function slv($str,$msg1,$msg2,$msg3) {
$str = (int)$str;
$str1 = abs($str) % 100;
$str2 = $str % 10;
if ($str1 > 10 && $str1 < 20) return $str .' '. $msg3;
if ($str2 > 1 && $str2 < 5) return $str .' '. $msg2;
if ($str2 == 1) return $str .' '. $msg1;
return $str .' '. $msg3;
}
function times($times=NULL){
$time = time();
if(($time-$times)<=60){
$timesp = slv((($time-$times)),'секунду','секунды','секунд').' назад';
return $timesp;
} else if(($time-$times)<=3600){$timesp = slv((($time-$times)/60),'минуту','минуты','минут').' назад';
return $timesp;
} else {
$today = date("j M Y", $time);
$today = date("j M Y", $time);
$yesterday = date("j M Y", strtotime("-1 day"));
$timesp=date("j M Y в H:i", $times);
$timesp = str_replace($today, 'Сегодня', $timesp);
$timesp = str_replace($yesterday, 'Вчера', $timesp);
$timesp = strtr($timesp, array ("Jan" => "Янв","Feb" => "Фев","Mar" => "Марта","May" => "Мая","Apr" => "Апр","Jun" => "Июня","Jul" => "Июля","Aug" => "Авг","Sep" => "Сент","Oct" => "Окт","Nov" => "Ноября","Dec" => "Дек",));
return $timesp;}
}
function times2($string) {
$day=floor($string/86400);
$hours=floor(($string/3600)-$day*24);
$min=floor(($string-$hours*3600-$day*86400)/60);
$sec=$string-($min*60+$hours*3600+$day*86400);
if($day > 0) $day2 = $day.' дней';
if($hours > 0 ) $hours2 = $hours.' часов';
if($min > 0 ) $min2 = $min.' минут';
if($sec > 0 ) $sec2 = $sec.' секунд';
return $day2.' '.$hours2.' '.$min2.' '.$sec2;
}
?>