Ok. ci sono riuscito, la posto per qualcuno a cui potrebbe interessare.
Antonio
Codice PHP:
function TempoPassato($time) {
$now = time();
$passato = $now - $time;
// 1 giorno = 86400;
// 1 ora = 3600
// 1 minuto = 60
if ($passato >= 86400) {
$tempo = $passato/86400
$tempo = number_format($tempo);
$tempo = $tempo . ' giorni fa';
} elseif ($passato >= 3600) {
$tempo = $passato/3600;
$tempo = number_format($tempo);
$tempo = $tempo . ' ore fa';
} else {
$tempo = $passato/60;
$tempo = number_format($tempo);
$tempo = $tempo . ' minuti fa';
}
return($tempo);
}
Dove $time e' il timestamp della data di rilascio articolo.
Chiaramente se si vuole aggiornare a settimane, mesi, bisogna aggiornare lo script. Arriva fino ai giorni