Calculate elapsed time in PHP

// get the time in microseconds before your search
$start_time = microtime(true);

/**
 * your code here
 * 
 */

// get the time in microseconds when you search is done
$end_time = microtime(true);

// finally subtract and print the time elapsed
echo $start_time - $end_time;

Leave a Comment