Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set system date and time
Message
From
02/02/2010 07:59:10
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Vista
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01447062
Message ID:
01447088
Views:
59
>Hi all,
>
>At startup of my VFP program, I would like to have the system date and time synchronised with a remote server. The date and time of the remote server is being fetched by the sql command getdate(). Is there an easy way to do this in VFP ??
>
>Best regards,
>Hans

I think you are asking how to set computer's datetime? Provided you can do that policy wise:
ltNow = Datetime()
? 'Now',Datetime()
SetSystemDate({^2002/1/3 17:30:33}) && set to an arbitrary time for testing
? 'Set to',Datetime() && get current datetime
SetSystemDate(m.ltNow)
? 'Set back to',Datetime()



Function SetSystemDate
  Lparameters tdDate
  Declare Integer SetLocalTime In win32api String @ lpTime
  Declare Integer GetLocalTime In win32api String @ lpTime
  Local lpCurrent, lcNewTime
  lpCurrent = Space(40)
  GetLocalTime(@lpCurrent) && save current

  lcNewTime = Num2Word(Year(m.tdDate))+;
    Num2Word(Month(m.tdDate))+;
    Num2Word(0)+;
    Num2Word(Day(m.tdDate))+;
    Num2Word(hour(m.tdDate))+;
    Num2Word(minute(m.tdDate))+;
    Num2Word(sec(m.tdDate))+;
    Num2Word(0)

  SetLocalTime(@lcNewTime)
  SetLocalTime(@lcNewTime)
EndFunc

Function Num2Word
  Lparameters tnDecimal
  Return Chr(m.tnDecimal%256)+Chr(Int(m.tnDecimal/256))
EndFunc
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform