CODE
function arabi_time_ago($input,$type = 'ty')
{
/*
get it from :http://css-tricks.com/snippets/php/time-ago-function/
translated by :codeboxy
*/
if($input > time()){
return false;
exit;
}
$period = array("ثانية", "دقيقة", "ساعة", "يوم", "اسبوع", "شهر", "سنة", "decade");
$periods = array("ثوانى", "دقائق", "ساعات", "ايام", "اسابيع", "شهور", "سنوات", "decade");
$periodtw = array("ثانيتان", "دقيقتان", "ساعتان", "يومان", "اسبوعان", "شهران", "سنتان", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $input;
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference == 2){
$x = $periodtw[$j];
return "منذ $x";
}elseif($difference != 1 and $difference <= 10) {
$x= $periods[$j];
return "منذ $difference $x";
}else{
$x = $period[$j];
return "منذ $difference $x";
}
}