<?php
$timestamp = "1331581669";
$gun = ((strtotime(date("d-m-Y"))-strtotime(date("d-m-Y", $timestamp)))/60/60/24)." Gün<br/>";
echo $gun;
$ay = floor($gun/30)." Ay ".round($gun%30)." Gün<br/>";
echo $ay;
$yil = floor($gun/365)." Yıl ".round(($gun%365)/30)." Ay<br/>";
echo $yil;
?>çıktı 1331581669 için
614 Gün
20 Ay 14 Gün
1 Yıl 8 Ay
şeklinde...
Şimdi farkettimde istenen bu değilmiş şöyle düzenledim:
<?php
$timestamp = "1346630400";
function r10yasi($timestamp){
$gun = ((strtotime(date("d-m-Y"))-strtotime(date("d-m-Y", $timestamp)))/60/60/24)." Gün<br/>";
if($gun>30){
if(floor($gun/30)>12){
return floor($gun/365)." Yıl ".round(($gun%365)/30)." Ay<br/>";
}else{
return floor($gun/30)." Ay ".round($gun%30)." Gün<br/>";
}
}else{
return $gun;
}
}
echo r10yasi($timestamp);
?>