You can use the microtime
function for this. From the documentation:
microtime
— Return current Unix timestamp with microseconds
If
get_as_float
is set toTRUE
, thenmicrotime()
returns a float, which represents the current time in seconds since the Unix epoch accurate to the nearest microsecond.
Example usage:
$start = microtime(true);
while (...) {
}
$time_elapsed_secs = microtime(true) - $start;