Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Server Time
Message
 
To
01/04/2004 20:09:18
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00891634
Message ID:
00892409
Views:
23
You can use WMI to get the time of any computer:
? GetServerTime('ServerName')

Function GetServerTime(tcComputer)
local lcComputer, loWMIService, loOperatingSystem, loOS, lcDateTime, ltDateTime

lcComputer		= Iif(Vartype(tcComputer)='C', tcComputer, 'LocalHost')
loWMIService		= GetObject("winmgmts:\\" + lcComputer + "\root\cimv2")

loOperatingSystem	= loWMIService.ExecQuery("Select * from win32_OperatingSystem")
for each loOS in loOperatingSystem
  lcDateTime		= loOS.LocalDateTime
next
ltDateTime		= Ctot(Transform(lcDateTime, '@R 9999-99-99T99:99:9999'))
return ltDateTime
This assumes that all computers are in the same TimeZone, otherwise you need to analize the last digits of lcDateTime to adjust it.

Hugo
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform