What potential pitfalls should be considered when using microtime() for script runtime calculation in PHP?

When using microtime() for script runtime calculation in PHP, it's important to consider that the result may not be accurate due to system clock changes or variations in server load. To mitigate this, it's recommended to use the hrtime() function which provides a high-resolution timer that is not subject to system clock changes.

$start = hrtime(true);

// Code to measure runtime

$end = hrtime(true);
$execution_time = ($end - $start) / 1e+9; // Convert to seconds
echo "Script executed in $execution_time seconds";