从 head 请求中获取上次更新日期和时间

发布于 2024-12-09 01:11:55 字数 1062 浏览 0 评论 0原文

我需要从这个数组中获取 GMT+1 的日期和时间。第一个问题是如何从标题数组中获取“日期”。其次,如何将其格式化为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 ) 

From this array I need the date and time according to GMT+1. First question is how do I get the ' date ' from the headers array. Second, how do I format it to 2011-10-09 08:40 (which is the format, and the time in 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 ) 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终陌 2024-12-16 01:11:55

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

我假设数组是变量 $pie

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

要创建日期时间对象,请参阅 这个。要格式化日期,请参见

First, to get the date you would have do do something like this:

I assume the array is the variable $pie

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

To create a datetime object, see this. And to format the date, see.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文