View Single Post
  #2  
Old 01-29-2008
awesomo awesomo is offline
Member - Class 3
 
Join Date: Jan 2007
Posts: 114
awesomo is on a distinguished road
Default

Here is a function from Pure-Esssence.net that will calculate the time diff. from now to a given timestamp.



http://pure-essence.net/2005/05/05/t...-php-function/

Code:
/* returns an array of [days],[hours],[minutes],[seconds] time left from now to timestamp given */ 
function timeleft($time_left=0, $endtime=null) { 
	if($endtime != null) 
		$time_left = $endtime - time(); 
	if($time_left > 0) { 
		$days = floor($time_left / 86400); 
		$time_left = $time_left - $days * 86400; 
		$hours = floor($time_left / 3600); 
		$time_left = $time_left - $hours * 3600; 
		$minutes = floor($time_left / 60); 
		$seconds = $time_left - $minutes * 60; 
	} else { 
		return array(0, 0, 0, 0); 
	} 
	return array($days, $hours, $minutes, $seconds); 
}
Reply With Quote