Sorun tam olarak nedir açarsan daha hızlı cevap alabilirsin.
Verdiğim kod işinizi görecektir.
<?php
header('Content-Type: text/html; charset=utf-8');
class DateAgo {
public $date;
public function ago()
{
$now = new DateTime;
$ago = new DateTime($this->date);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
'y' => 'yıl',
'm' => 'ay',
'w' => 'hafta',
'd' => 'gün',
'h' => 'saat',
'i' => 'dakika',
's' => 'saniye',
);
foreach ($string as $k => &$v)
{
if ($diff->$k) {
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? '' : '');
} else {
unset($string[$k]);
}
}
return $string ? implode(', ', $string) . ' önce' : 'şimdi';
}
}
$ago = new DateAgo();
$ago->date = "12.05.2016 18:20:50";
echo $ago->ago();
Tam istediğim gibi. Teşekkürler.