Converting Seconds in PHP
$seconds = time();
$time = str_pad(intval(intval($seconds/3600)),2,"0",STR_PAD_LEFT).":"
. str_pad(intval(($seconds / 60) % 60),2,"0",STR_PAD_LEFT).":"
. str_pad(intval($seconds % 60),2,"0",STR_PAD_LEFT) ;
Now let's use this code for printing the time a particular script (or function) takes to run. Snazzy !
$start = time();
//--> some code here
$finish = time();
$sec = ($finish - $start);
$runtime = str_pad(intval(intval($sec) / 3600),2,"0",STR_PAD_LEFT).":"
. str_pad(intval(($sec / 60) % 60),2,"0",STR_PAD_LEFT).":"
. str_pad(intval($sec % 60),2,"0",STR_PAD_LEFT) ;