All pastes #158028 Raw Edit

lol

public php v1 · immutable
·published 2006-09-01 22:22 UTC
rendered paste body
<?phpfunction decent_time ($secs,$format = "hms") {	$remains = $secs;	if (strpos($format,"d") !== false && $remains/86400 >= 1) {		$handle = $remains/86400;		if($handle >= 2) {			$total = $total . floor($handle) . "days ";		} elseif($handle >= 1) {			$total = $total . "1 day ";		}		$remains -= floor($handle) * 86400;	}	if (strpos($format,"h") !== false && $remains/3600 >= 1) {		$handle = $remains/3600;		if($handle >= 2) {			$total = $total . floor($handle) . " hours ";		} elseif($handle >= 1) {			$total = $total . "1 hour ";		}		$remains -= floor($handle) * 3600;	}	if (strpos($format,"m") !== false && $remains/60 >= 1) {		$handle = $remains/60;		if($handle >= 2) {			$total = $total . floor($handle) . " minutes ";		} elseif($handle >= 1) {			$total = $total . "1 minutes ";		}		$remains -= floor($handle) * 60;	}		if (strpos($format,"s") !== false && $remains >= 1) {		$handle = $remains;		if($handle >= 2) {			$total = $total . $handle . " seconds";		} elseif($handle >= 1) {			$total = $total . "1 second";		}		$remains -= $handle;	} else {		$total = substr($total,0,-1);	}	return $total;		}echo "Time 3600: ".decent_time(3600)."<br>\r\n";echo "Time 3601: ".decent_time(3601)."<br>\r\n";?>