PHP : Hace Script / Ago Script
if we call with a timestamp of a month ago, he print "Hace 1 mes". If you want this in english should traduction. Sorry my english
1 2 function hace($timestamp) 3 { 4 $diferencia = time() - $timestamp; 5 if($diferencia > 0) 6 { 7 $periodo = array("segundo", "minuto", "hora", "dia", "semana", "mes" , "año", "decada"); 8 $longitud = array( "60" , "60" , "24" , "7" , "4.35", "12" , "10" ); 9 10 for($j = 0; $diferencia >= $longitud[$j]; $j++) 11 $diferencia /= $longitud[$j]; 12 13 $diferencia = round($diferencia); 14 15 if($diferencia != 1) 16 { 17 if($periodo[$j] == "mes") 18 $periodo[$j].= "es"; 19 else 20 $periodo[$j].= "s"; 21 } 22 23 return "Hace <b>".$diferencia."</b> ".$periodo[$j]; 24 } 25 }