dongyuqie4322 2011-10-20 03:11
浏览 30
已采纳

请求日期在apache_request_header()中

I am quite confused whether is it possible to get the request date on HTTP Request. Like in the Response header:

Date: Thu, 20 Oct 2011 03:03:40 GMT

I tried var_dump(apache_request_header()) and print_r($_SERVER) to attempt if the request date is in there, but no luck.

Any ideas? Thanks.

  • 写回答

3条回答 默认 最新

  • doulan8152 2011-10-20 03:41
    关注

    apache_request_header does not return the Request Date/Time. It mainly has the following information

    Accept: */*
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0
    Host: www.example.com
    Connection: Keep-Alivev
    

    The best way to find out when the page was requested is to use.

    $_SERVER[’REQUEST_TIME’] 
    

    Using $_SERVER is more reliable and uses less resources.

    EDIT

    $DT = date("D, d M Y H:i:s", $_SERVER['REQUEST_TIME']);
    echo "Time page was requested: ",$DT;
    

    Will output something like the folowing

    Time page was requested: Thu, 20 Oct 2011 23:02:29
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用