Click to See Complete Forum and Search --> : connecting to the internet's atomic clock
funkheads
Dec 5th, 1999, 07:03 PM
does anyone know how to retrieve time from the internet atomic clock?
--michael
chrisjk
Dec 6th, 1999, 03:56 PM
what is the internet's atomic clock?? I've never heard of it...
funkheads
Dec 9th, 1999, 02:21 AM
it's the government's clock that uses atoms (somehow) to tell time. it is accurate to something like a billionth of a second. i have seen programs that connect to it to retrieve and set the time for their own computer. but since i am writing a clock program i just thought it might be a nice little added feature to add the ability to retrieve the "perfect atomic time" that's all.
--michael
Gimpster
Dec 9th, 1999, 03:20 AM
Just a little note in case anyone is wondering. The atomic clock works by measuring the oscillations of certain elements like Cesium and Hydrogen. These clocks are accurate to about 1 second in a million years. One site you could check out is:
http://www.cstv.to.cnr.it/toi/uk/atomtime.html
------------------
Ryan
corneslen@hotmail.com
ICQ# 47799046
Antonio Begue
Dec 9th, 1999, 10:43 AM
http://www.eecis.udel.edu/~ntp/software.html
tycho.usno.navy.mil
look at this pages
the first have some programs to retrive the time from the atomic clock
Antonio Begue
Dec 9th, 1999, 11:26 AM
http://www.mhn.org/~graham/nettime.html
here are a code in c++ that do what you want
Frans C
Dec 9th, 1999, 10:43 PM
Ok, I think I figured it out.
Draw a winsock control and a command button on a form, and paste the code. It will synchronize your system time with the atom clock of the nist institute.
Option Explicit
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Sub GetTime()
Dim TimeOut As Boolean
Dim StartTime As Single
TimeOut = False
StartTime = Timer
Winsock1.RemoteHost = "time.nist.gov"
Winsock1.RemotePort = 13
Winsock1.Connect
While (Not Winsock1.State = 7) Or TimeOut
DoEvents
TimeOut = Timer > StartTime + 5
Wend
End Sub
Private Sub Command1_Click()
Call GetTime
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData, vbString
Call SetTime(strData)
Winsock1.Close
Winsock1.LocalPort = 0
Unload Me
End Sub
Private Sub SetTime(ByVal TimeString As String)
Dim RetVal As Long
Dim udtTime As SYSTEMTIME
Dim TempDate As Date
If Val(Mid(TimeString, 31, 1)) < 2 Then 'server is healthy enough
TempDate = CDate(Val(Mid(TimeString, 2, 5)) - 15018)
With udtTime
.wYear = Year(TempDate)
.wDayOfWeek = 0
.wMonth = Month(TempDate)
.wDay = Day(TempDate)
.wHour = Val(Mid(TimeString, 17, 2))
.wMinute = Val(Mid(TimeString, 20, 2))
.wSecond = Val(Mid(TimeString, 23, 2))
.wMilliseconds = 0
End With
RetVal = SetSystemTime(udtTime)
End If
End Sub
Juan Carlos Rey
Dec 10th, 1999, 07:58 AM
Just a silly question. Those atomic clocks are impressively accurate,
but are there not huge delays in the net that you can not control?
I used Tracert (in a DOS window) and noticed delays of several seconds.
Don't those delays add to the retrieved time?
[This message has been edited by Juan Carlos Rey (edited 12-10-1999).]
Frans C
Dec 10th, 1999, 10:25 PM
The Nist institute adds a certain time to compensate for network delays. But I'm sure the accuracy isn't the same as the clock itselve. However, I noticed the connection doesn't take seconds but just a second at the most. (the Netherlands to the US and back)
[This message has been edited by Frans C (edited 12-11-1999).]
funkheads
Dec 11th, 1999, 03:57 PM
damn Frans C...you are the man!! thank you so much. i have been trying to do this for a while now and kept screwing it up when it came to passing the retrieved time to my system's clock. thanks so very much for figuring this one out for me. liek i said...you are the man!!!
--michael
Actually, I used the AtomTime98 program to match my computer clock with the atomic clock and It is almsot exact. If I look at my cable box my computer clock is about 1/2 a second differnt.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.