Return to Snippet

Revision: 51185
at September 16, 2011 06:13 by aristoworks


Initial Code
function seconds($seconds) {

		// CONVERT TO HH:MM:SS
		$hours = floor($seconds/3600);
		$remainder_1 = ($seconds % 3600);
		$minutes = floor($remainder_1 / 60);
		$seconds = ($remainder_1 % 60);
		
		// PREP THE VALUES
		if(strlen($hours) == 1) {
			$hours = "0".$hours;
		}
		
		if(strlen($minutes) == 1) {
			$minutes = "0".$minutes;
		}
		
		if(strlen($seconds) == 1) {
			$seconds = "0".$seconds;
		}
		
		return $hours.":".$minutes.":".$seconds;

		}

Initial URL
http://www.aristoworks.com

Initial Description
This came in handy when I was working with Hour / Minute / Second dropdown on a page.

Initial Title
Convert Seconds To HH:MM:SS

Initial Tags


Initial Language
PHP