Getting server time from a client stack accessing it

Andre Rombauts andre.rombauts at win.be
Tue Apr 6 08:27:44 EDT 2004


Great tip Frank, indeed! Thanks. It is working fine... Here is the script I
made. The mouseUp is a button handler being invoked after typing a server
URL under the form www.name.domain. The server headers contain the Internet
time but without the UTC + offset, thus the function adds +0000 to set it
correctly the GMT time returned.

Once more an example of how easy it is to 'create' with Run Rev!

=====

on mouseUp
  put empty into field "fDate"
  put getServerTime (the text of field "inputURL") into varDate
  convert varDate from internet date and time to system date and time
  put varDate into field "fDate"  
end mouseUp

function getServerTime serverURL
  put "http://" & serverURL into varURL
  get URL varURL
  put libURLLastRHHeaders() into varDate 
  set itemDelimiter to space
  return item 2 to 6 of line lineOffset("Date:",varDate) of varDate & "
+0000"
end getServerTime 

=====

> Most servers return the current server time in the Date: HTTP 
> header, so you should be able to ask for any page on the 
> server to get the time.  The date is formatted in a standard 
> "Internet" time (see the RR docs).
> 
> The response headers will look like this:
> 
> HTTP/1.1 200 OK\r\n
> Server: foo\r\n
> Date: Mon, 05 Apr 2004 16:59:24 GMT\r\n
> ...\r\n
> \r\n
> 
> 
> -- Frank




More information about the use-livecode mailing list