Grabbing the Date and Time From a Time Server on the Internet
Peter M. Brigham, MD
pmbrig at gmail.com
Mon Aug 15 15:15:05 EDT 2011
I'll try sending this again, revised (third time -- someone let me know please if it's getting through). It returns the time fast enough (with a speedy connection) to be within a second or so.
You can fetch the time from the U.S. Naval Observatory atomic clock. This assumes an internet connection, though. If what you want to do is timestamp something, just fetch the "universal time" line (line 6 of the HTML returned):
put line 6 of URL "http://tycho.usno.navy.mil/cgi-bin/timer.pl" into t
-- returns "<BR>Aug. 15, 19:12:46 UTC" & tab & tab & "Universal Time"
replace "<BR>" with empty in t
set the itemdelimiter to tab
delete item 2 to -1 of t
set the itemdelimiter to comma
delete word -1 of t
put t into ts
put the short date into di
convert di to dateitems
put item 1 of di into tYr
put space & tYr after item 1 of t
put space & tYr after item 1 of ts
replace comma with empty in t
replace comma with empty in ts
convert ts to seconds
put t & cr & ts
return t -- if you want "Aug. 15, 19:12:46" or,
return ts -- if you want the seconds
Peter M. Brigham
pmbrig at gmail.com
On Aug 15, 2011, at 1:25 PM, Bob Sneidar wrote:
> This returns a ton of html, from which the date time can be filtered using "<H2>*", but since it takes about 30 seconds to run, and returns 32 entries, I am not sure how useful this would for him, if he wanted an exact time (within a second or two).
> Time servers are NTP:\\ aren't they? Looks like the revURL library does not support NTP, or not that I can see. Any attempt to use it in a URL returns empty in it and invalid URL: in the result.
> A quick browse for http based time servers came up dry.
> On Aug 13, 2011, at 11:15 AM, Mark Wieder wrote:
>> Saturday, August 13, 2011, 10:33:29 AM, you wrote:
>>> Taking another kick at the cat here. I’d like to use something like
>>> get url (http://[time server address])
>> How's this?
>> -Mark Wieder
>> mwieder at ahsoftware.net
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode