Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?
  2. function sureHesapla($zaman,$suan,$ayrinti=2){
  3. $tarihler=array(365*24*60*60 => "yil",
  4. 30*24*60*60 => "ay",
  5. 7*24*60*60 => "hafta",
  6. 24*60*60 => "gun",
  7. 60*60 => "saat",
  8. 60 => "dakika",
  9. 1 => "saniye");
  10. if($suan>$zaman){
  11. $gecen=$suan-$zaman;
  12. if($gecen<5){$cikti='5 Saniyeden daha az sure once.';}
  13. }else{
  14. $gecen=$zaman-$suan;
  15. if($gecen<5){ $cikti='5 Saniyeden daha az sure gecmis.';}
  16. }
  17. $cikti=array();
  18. $cikis=0;
  19. if($gecen>5){
  20. foreach($tarihler as $sayi=>$kelime){
  21. if($cikis>=$ayrinti || ($cikis<0 && $sayi<60)) break;
  22. // ara sureyi bulalim
  23. $arasure=floor($gecen/$sayi);
  24. if($arasure>0){
  25. $cikti[]=$arasure.' '.$kelime;
  26. $gecen-=$arasure*$sayi;
  27. $cikis++;
  28. }else if($cikis>0) $cikis++;
  29. }
  30. $cikti=implode(' ve ',$cikti).' once';
  31. }
  32.  
  33.  
  34. return $cikti;
  35.  
  36. }
  37. $belirliGun = strtotime('2011-09-20 17:00:43');
  38. $suan=strtotime(date("j-n-Y H:i:s"));
  39.  
  40. echo sureHesapla($belirliGun,$suan,5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement