473,405 Members | 2,421 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,405 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 2007
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.