How to track exection time of each request in Hour:minutes:seconds microseconds ?
I have done as below but how to track it with microseconds?
public function actionIndex(){
$start_time = date("H:i:s");
// Functionality to execute ...
$end_time = date("H:i:s");
$diff = strtotime($end_time)-strtotime($start_time);
$execution_time = gmdate("H:i:s",$diff);
}
Edit 1 - is it right way?
$start_time = microtime(true);
// looping or functionality ...
$time_taken = round(microtime(true) - $start_time,4);
list($sec,$msec)= explode(".", $time_taken);
$execution_time = date("i",$sec)."m : ".date("s",$sec)."s : ".$msec."ms";