Resolved Get current date from HTTP or FTP sever?

Joined
Aug 14, 2008
Messages
7
Programming Experience
Beginner
Hello... This is hopefully a super simple question on an advanced topic.

I have a leased VPS, so I have any kind of access I need to it. I am writing an application in Visual Basic 2005 and all I want to do is make some sort of call out to the web or ftp server to ask what the current server date is. (I want to compare it to the local computer date to make sure they are in agreement.)

Is anybody available to help me with my Saturday morning problem? :) Spent my Friday night trying to make different API calls out to WebBrowser1 and trap the results (unsuccessfully). Surely there has got to be a cleaner / easier way.

Thank you in advance for any helpful direction.

-Geoffrey
 
Last edited:
Resolved: Get Date From Web Server

Got it.

First I wrote sync.php and uploaded it to my server:
HTML:
<?php;$today = date("m-d-y");Print $today;?>

Then I pointed my not-visible webbrowser1 at the URL with sync.php and read result with WebBrowser1.Document.Body.InnerText

I found a lot of baffling (to a beginner) answers on the web about reading the date value from http headers, but in the end simplicity won the day.

Too bad it took two days to think it up. :worked_till_5am:

-Geoffrey
 
Reading the date value from Http headers is not very complicated:
        Dim request = Net.WebRequest.Create("http://server")
        request.Method = Net.WebRequestMethods.Http.Head
        Dim response = request.GetResponse
        response.Close()
        Dim utc = Date.Parse(response.Headers("Date"))
        Dim local = utc.ToLocalTime

It is not possible with Ftp protocol. (you can find suggestions to upload an empty file, check its date stamp, then delete it)
 
Back
Top