- POSTEADO POR WAO -
Este codigo...
comments.class.php:
[PHP] /*
/ Relative Date / Time Strings
/ Credits: Zach Johnson - www.zachstronaut.com
/ Here we convert a the unix timestamp of when the comment was posted
/ to a relative time since that original date/time. (ei. xx hours ago)
*/
public function time_elapsed_string($ptime)
{
$etime = time() - $ptime;
if ($etime < 1) {
return '0 segundos';
}
$a = array( 12 * 30 * 24 * 60 * 60 => 'año',
30 * 24 * 60 * 60 => 'mes',
24 * 60 * 60 => 'dia',
60 * 60 => 'hora',
60 => 'minuto',
1 => 'segundo'
);
foreach ($a as $secs => $str) {
$d = $etime / $secs;
if ($d >= 1) {
$r = round($d);
return $r . ' '.$str . ($r > 1 ? 's' : '') . ' ';
}
}
}
} [/PHP]
lo he traducido del ingles al español, se puede modificar para que en vez de "Posteado por ..... hace x horas..." sea "Posteado por.... el 3 Octubre 2010 @ 15:08 (GMT +2)"?
|