Now()

C

Cameron Sutherland

There may be an easier way to do this but here goes. In
DOS you can get the time from a server on the network with
Net Time. you can output that and get the results:

Private Sub GetTime() as Date
Dim strLineRead As String
Dim intMyPos As Integer
Shell (Environ$("COMSPEC") & " /C net
time /domain:yourdomainname >>C:\gettime.txt")
Open "C:\gettime.txt" For Input As #1 'open text file
Input #1, strLineRead 'read the first line of text
Close #1 'close the text file
intMyPos = InStr(1, strLineRead, " is ", 1) 'get position
GetTime= Mid(strLineRead, intMyPos + 4, Len
(strLineRead) - intMyPos) 'strip out only date time
End Sub

-Cameron Sutherland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top