mesela 150 sn bunu 2:30 (30 küçük olucak yukarıda asılı şekilde)
nasıl yapabiliriz.
saniyeleri nasıl dakikaya çeviririz.?
4
●745
- 16-12-2008, 18:47:32
- 16-12-2008, 18:51:50Üyeliği durduruldusaniyeyi saat:dakika:saniye olarak dönüştürür;
function sec2hms ($sec, $padHours = false) { // holds formatted string $hms = ""; // there are 3600 seconds in an hour, so if we // divide total seconds by 3600 and throw away // the remainder, we've got the number of hours $hours = intval(intval($sec) / 3600); // add to $hms, with a leading 0 if asked for $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':' : $hours. ':'; // dividing the total seconds by 60 will give us // the number of minutes, but we're interested in // minutes past the hour: to get that, we need to // divide by 60 again and keep the remainder $minutes = intval(($sec / 60) % 60); // then add to $hms (with a leading 0 if needed) $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':'; // seconds are simple - just divide the total // seconds by 60 and keep the remainder $seconds = intval($sec % 60); // add to $hms, again with a leading 0 if needed $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); // done! return $hms; } ?> - 16-12-2008, 20:32:45
function aralik($girdi) { $saniye = 1; $dakika = 60; $saat = 3600; $gun = 86400; $cikti = ""; # Don't touch, only watch for ($i=0;($i*$gun)<=$girdi;$i++) { $toplamgun = $i; } if ( $toplamgun > 0 ) { $girdi = $girdi - ($gun*$toplamgun); $cikti .= "$toplamgun gün "; } for ($i=0;($i*$saat)<=$girdi;$i++) { $toplamsaat = $i; } if ( $toplamsaat > 0 ) { $girdi = $girdi - ($saat*$toplamsaat); $cikti .= "$toplamsaat saat "; } for ($i=0;($i*$dakika)<=$girdi;$i++) { $toplamdakika = $i; } if ( $toplamdakika > 0 ) { $girdi = $girdi - ($dakika*$toplamdakika); $cikti .= "$toplamdakika dakika "; } if ( $girdi > 0 ) { $cikti .= "$girdi saniye"; } return $cikti; } echo aralik(61); // 1 dakika 1 sn.bilgisayarımda kütüphanede duruyor.. Sanırım ceviz den almıştım kaynağı tam hatırlamıyorum..