I've fooled around with creating a file on a mapped network drive and checking out the time of that, but its not very consistent. I realize it's more work than you probably want, but using a DCOM component on the server would be a pretty good way to do it, or if necessary a web service. -- Mike Helland
If you're using a SQL Server back-end then you can just pass through a
SELECT GETDATE() as CurrentTime
and read the result from the cursor SQLEXEC returns -- Andrew Coates
Another thought: if you're running an NT-based OS on the workstation, set up a scheduled task that executes a
NET TIME
command against the server every hour or so - you should be pretty much in sync most of the time -- Andrew Coates
There's the NetRemoteTOD api call too (NT only though) -- John Carter
By chance I just found KB Q249716 that give an example in VFP for NetRemoteTOD -- John Carter
The example given in KB Q249716 doesn't work. See below for my code that uses NetRemoteTOD correctly -- Mark Austen
Here is my program that does as Mike says above, create a file on the server and read its time.
#DEFINE _SERVER "svrsbdell1"
#DEFINE _PATH "storage"
function ServerTime( cServerName, cPath )
local cUNC,cTmpFile,tServerTime
if empty( cServerName )
cServerName = _SERVER
endif
if empty( cPath )
cPath = _PATH
endif
cTmpFile = '!'+right(SYS(2015),7)+'.tmp'
cUNC = addbs('\\'+cServerName)
if left(cPath,1) = '\'
cPath = subs(cPath,2)
endif
cUNC = addbs(cUNC+cPath)+cTmpFile
set alternate to ( cUNC )
?
set alternate to
tServerTime = FDATE( cUNC, 1 )
delete file ( cUNC )
return tServerTime
Read more