$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) ;
J Cornelius is a software developer, Web developer, and Formula 1 fan in Atlanta GA. He has a strange affinity for odd numbers, european sports cars, thoughtful analogies, and is hopelessly addicted to chips & salsa. Read more
Was it good for you?
Post to Digg Post to del.icio.us Post to ma.gnolia Post to Furl Post to Mixx