As noted in the PHP documentation, the $_SERVER
superglobal array contains two elements, REQUEST_TIME
and REQUEST_TIME_FLOAT
, both of which contain the timestamp of the start of the request, in varying precision levels.
I am currently using the following snippet to include the time (in milliseconds) it took the server to generate the page in the footer of the page:
round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000,2);
It returns an accurate value (can't really check, but it seems to match the time it takes the browser to start loading the page), but I am wondering which exact moment do the $_SERVER['REQUEST_TIME']
and $_SERVER['REQUEST_TIME_FLOAT']
variables contain the timestamp of? While I believe that the differences between those timestamps aren't significant, I would like to know which moment is the timestamp taken at. Is it the time when the request was sent, when the request was received, when PHP started parsing the document or something else?
$_SERVER
is populated by the webserver processing the request. – Battaglia