473,244 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,244 software developers and data experts.

Date from HTTP headers

I've got a PHP script that's using fopen to connect to a remote web
server and pick up data.

I've run into a problem in calculating elapsed time. The remote web
server outputs a time and I'd like to calculate the difference between
that time and the current time. The problem is that the time on the
remote server isn't in sync with the time on my server (off by about 5
minutes) and this throws off the elapsed time calculations. I know
that the server's date/time are included in the HTTP headers, ex:
Date: Sat, 27 Mar 2004 01:25:25 GMT

So, I'm wondering if there's an easy way to grab that date from the
remote server so that the calculations are more accurate.

Thanks in advance.

-M
Jul 17 '05 #1
1 1995
On Sat, 27 Mar 2004 01:31:40 -0000, Marc <ma**@svn.net> wrote:
I've got a PHP script that's using fopen to connect to a remote web
server and pick up data.

I've run into a problem in calculating elapsed time. The remote web
server outputs a time and I'd like to calculate the difference between
that time and the current time. The problem is that the time on the
remote server isn't in sync with the time on my server (off by about 5
minutes) and this throws off the elapsed time calculations. I know
that the server's date/time are included in the HTTP headers, ex:
Date: Sat, 27 Mar 2004 01:25:25 GMT

So, I'm wondering if there's an easy way to grab that date from the
remote server so that the calculations are more accurate.


<pre>
<?php
$fp = fopen('http://localhost/', 'r');
var_dump(stream_get_meta_data($fp));
?>
</pre>

Output:

array(10) {
["wrapper_data"]=>
array(6) {
[0]=>
string(15) "HTTP/1.1 200 OK"
[1]=>
string(35) "Date: Sat, 27 Mar 2004 01:39:57 GMT"
[2]=>
string(42) "Server: Apache/2.0.49 (Win32) PHP/5.0.0RC1"
[3]=>
string(20) "Content-Length: 7172"
[4]=>
string(17) "Connection: close"
[5]=>
string(37) "Content-Type: text/html;charset=utf-8"
}
["wrapper_type"]=>
string(4) "HTTP"
["stream_type"]=>
string(10) "tcp_socket"
["mode"]=>
string(2) "r+"
["unread_bytes"]=>
int(4140)
["seekable"]=>
bool(false)
["uri"]=>
string(17) "http://localhost/"
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
}

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mohan | last post by:
Hi All, I am using web browser control in a VB 6.0 client server application to print reports. I am writing the report into a HTML file and displays the report to the user using the code,...
3
by: praba kar | last post by:
Dear All, I have doubt regarding date string to time conversion function. In Python I cannot find flexible date string conversion function like php strtotime. I try to use following type...
13
by: Dr John Stockton | last post by:
Javascript date strings can have a one-letter postfix; it is taken as indicating time zone (not J, which causes NaN). // IIRC, VB accepts A & P in that location, for AM & PM. In my MS IE 4, the...
3
by: Dave | last post by:
I recently did a search of my very first web site, through WebArchive, located here: http://web.archive.org/collections/web.html However, I'm seeking the creation date of my web site (and...
2
by: Giulio | last post by:
I make an import of a huge file txt table with headers at each page and date format as "20.12.2004" in order to use the data I first qo a query that exclude all line representing the headers...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
7
by: Ramon | last post by:
Hello, when I send an email using the mail() function, I get a Runtime Notice: date() : It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ...
2
by: Stefan Antonelli | last post by:
Hi, i have to convert several timestamps. The given format, eg "yyyy-mm-dd hh:mm:ss" has to be converted to an epoch string. Is there any proper way to do this? If not, i have to split the...
1
by: Akhenaten | last post by:
Probably something simple but all email I send via mail() is received with an "unknown date" stamp. Am I missing something in my header? Code as follows: ***************************** <?php...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.