Convert Seconds To Duration Time Format


	$seconds_input = $video_duration;		//The value in seconds (e.g. 1568.782)
	$hours = (int)(($minutes = (int)($seconds = (int)($milliseconds = (int)($seconds_input * 1000)) / 1000) / 60) / 60);
	$duration_string = $hours.':'.($minutes%60).':'.($seconds%60).((($milliseconds%1000) === 0) ? '' : '.'.rtrim($milliseconds%1000, '0'));
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *