<?php
function getRelativeTime($date) {
$diff = time() - strtotime($date);
if ($diff<60)
return strtr(ngettext("vor einer Sekunde", "vor %time% Sekunden", $diff), array("%time%" => $diff));
$diff = round($diff/60);
if ($diff<60)
return strtr(ngettext("vor einer Minute", "vor %time% Minuten", $diff), array("%time%" => $diff));
$diff = round($diff/60);
if ($diff<24)
return strtr(ngettext("vor einer Stunde", "vor %time% Stunden", $diff), array("%time%" => $diff));
$diff = round($diff/24);
if ($diff<7)
return strtr(ngettext("vor einem Tag", "vor %time% Tagen", $diff), array("%time%" => $diff));
$diff = round($diff/7);
if ($diff<4)
return strtr(ngettext("vor einer Woche", "vor %time% Wochen", $diff), array("%time%" => $diff));
$diff = round($diff/4);
if ($diff<12)
return strtr(ngettext("vor einem Monat", "vor %time% Monaten", $diff), array("%time%" => $diff));
return strtr(_("am %date% um %time%"), array("%time%" => strftime('%X', strtotime($date)),
"%date%" => strftime('%x', strtotime($date))
));
}
?>
Это мое решение.