我很困惑是否有可能在 HTTP 请求上获取请求日期。就像在 Response header 中一样:
Date: Thu, 20 Oct 2011 03:03:40 GMT
我尝试了 var_dump(apache_request_header())
和 print_r($_SERVER)
来尝试请求日期是否在其中,但没有成功。
有什么想法吗?谢谢。
最佳答案
apache_request_header 不返回请求日期/时间。主要有以下信息
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0
Host: www.example.com
Connection: Keep-Alivev
找出页面何时被请求的最好方法是使用。
$_SERVER[’REQUEST_TIME’]
使用 $_SERVER 更可靠并且使用的资源更少。
编辑
$DT = date("D, d M Y H:i:s", $_SERVER['REQUEST_TIME']);
echo "Time page was requested: ",$DT;
会输出类似下面的内容
Time page was requested: Thu, 20 Oct 2011 23:02:29
关于php - apache_request_headers() 中的请求日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7830700/