【问题标题】:Get last update date and time from head request从头请求中获取上次更新日期和时间
【发布时间】:2011-10-09 07:44:28
【问题描述】:

从这个数组中,我需要根据 GMT+1 的日期和时间。第一个问题是如何从 headers 数组中获取“日期”。其次,如何将其格式化为 2011-10-09 08:40 (这是格式,以及 GMT+1 中的时间)。

Array ( [headers] => Array ( [Date] => Sun, 09 Oct 2011 07:40:10 GMT [Server] => Apache [Last-Modified] => Sun, 09 Oct 2011 07:39:29 GMT [ETag] => "10c8000a" [Accept-Ranges] => bytes [Content-Length] => 198311 [Content-Type] => image/jpeg ) [info] => Array ( [url] => http://domain.no/webcamera/broadcast.jpg [content_type] => image/jpeg [http_code] => 200 [header_size] => 208 [request_size] => 214 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.208861 [namelookup_time] => 0.003067 [connect_time] => 0.025592 [pretransfer_time] => 0.0256 [size_upload] => 0 [size_download] => 198311 [speed_download] => 949487 [speed_upload] => 0 [download_content_length] => 198311 [upload_content_length] => 0 [starttransfer_time] => 0.049787 [redirect_time] => 0 [certinfo] => Array ( ) ) [curl_handle] => Resource id #2 ) 

【问题讨论】:

    标签: php datetime http-headers httpwebrequest


    【解决方案1】:

    首先,要获取日期,您需要执行以下操作:

    我假设数组是变量 $pie

    $pie['headers']['Date']
    

    要创建日期时间对象,请参阅this。并格式化日期,see

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-18
      相关资源
      最近更新 更多