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