Location: PHPKode > projects > phpCAMALEO > common/fun2inc/time_format.inc
<?php
if(!function_exists('time_format'))
{
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Desc
	#
	function time_format($time,$flag='')	/* $time value in seconds */
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		$days='';
		if($time>=86400 && $flag!='H')
		{
			#
			#	More than 1 day
			#
			$dval=($time/86400);
			$daystime=intval($dval);
			if($flag=='') { $days=$daystime.' D '; } else { $days=$daystime.$flag; }			
			$leftoverdays=($time%86400);
			$time=$leftoverdays;
			if($leftoverdays==0)
			{
				$hourtime=str_pad(0,2,'0',STR_PAD_LEFT);
				$minutetime=str_pad(0,2,'0',STR_PAD_LEFT);
				$secondtime=str_pad(0,2,'0',STR_PAD_LEFT);
				return($days."$hourtime:$minutetime:$secondtime");
			}
		}
		if($time>=3600) 
		{
			$hval=($time/3600);
			$hourtime=intval($hval);
			$leftoverhours=($time%3600);
			$mval=($leftoverhours/60);
			$minutetime=intval($mval);
			$leftoverminutes=($leftoverhours%60);
			$secondtime=intval($leftoverminutes);
			$hourtime=number_format($hourtime,0,',','.');
			$minutetime=str_pad($minutetime,2,'0',STR_PAD_LEFT);
			$secondtime=str_pad($secondtime,2,'0',STR_PAD_LEFT);
			return($days."$hourtime:$minutetime:$secondtime");
		}
		if($time>=60)
		{
			$hourtime=0;
			$mval=($time/60);
			$minutetime=intval($mval);
			$leftoverminutes=($time%60);
			$secondtime=intval($leftoverminutes);
			$hourtime=str_pad($hourtime,2,'0',STR_PAD_LEFT);
			$minutetime=str_pad($minutetime,2,'0',STR_PAD_LEFT);
			$secondtime=str_pad($secondtime,2,'0',STR_PAD_LEFT);
			return($days."$hourtime:$minutetime:$secondtime");
		}
		if($time<0) { $secondtime=0; } else { $secondtime=$time; }
		$hourtime=str_pad(0,2,'0',STR_PAD_LEFT);
		$minutetime=str_pad(0,2,'0',STR_PAD_LEFT);
		$secondtime=str_pad($secondtime,2,'0',STR_PAD_LEFT);
		return($days."$hourtime:$minutetime:$secondtime");
	}
}
?>
Return current item: phpCAMALEO