how to change the pc date & time? 
Author Message
 how to change the pc date & time?

Hi,

somebody knows how to change the date& time of the PC where I am running VFP
6.0 application, other that using the command RUN DATE (datetime value) ?

I need this ti be done without user intervention and without DOS windows

thanks

Oscar Taboada



Sun, 04 Sep 2005 07:10:37 GMT  
 how to change the pc date & time?
Use the API SetSystemTime

This should do it for you...

local lcString, liYear, liMonth, liDOW, liDay, liHour, liMin, liSec, liMS
Declare SetSystemTime ;
    in kernel32 ;
    string
liYear = 2005
liMonth = 9
liDay = 26
liDOW = dow(date(liYear, liMonth, liDay), 2)
liHour = 20
liMin = 53
liSec = 2
liMS = 3
lcString = StringIt(liYear) + ;
    StringIt(liMonth) + ;
    StringIt(liDOW) + ;
    StringIt(liDay) + ;
    StringIt(liHour) + ;
    StringIt(liMin) + ;
    StringIt(liSec) + ;
    StringIt(liMS)
SetSystemTime(lcString)

Function StringIt
    lPara liNum
    return chr(mod(liNum, 256)) + chr(int(liNum/256))
endFunc

Be careful, on my system, XP, this set the clock to 9:53pm because of change
to daylight saving.

Andrew R.


Quote:
> Hi,

> somebody knows how to change the date& time of the PC where I am running
VFP
> 6.0 application, other that using the command RUN DATE (datetime value) ?

> I need this ti be done without user intervention and without DOS windows

> thanks

> Oscar Taboada



Sun, 04 Sep 2005 16:00:20 GMT  
 how to change the pc date & time?
Andrew,
Actually this API call expects a UTC (or Greenwich Mean) DateTime, which doesn't care about Daylight
savings or even the TimeZone you are in. The OS will automatically adjust the UTC time given to use
the local DateTime settings. i.e. If I wanted to set my time in Lansing Mi, USA to 9:10 am this
morning, I'd use 14:10 (GMT).

Rick

Quote:

> Use the API SetSystemTime

> This should do it for you...

> local lcString, liYear, liMonth, liDOW, liDay, liHour, liMin, liSec, liMS
> Declare SetSystemTime ;
>     in kernel32 ;
>     string
> liYear = 2005
> liMonth = 9
> liDay = 26
> liDOW = dow(date(liYear, liMonth, liDay), 2)
> liHour = 20
> liMin = 53
> liSec = 2
> liMS = 3
> lcString = StringIt(liYear) + ;
>     StringIt(liMonth) + ;
>     StringIt(liDOW) + ;
>     StringIt(liDay) + ;
>     StringIt(liHour) + ;
>     StringIt(liMin) + ;
>     StringIt(liSec) + ;
>     StringIt(liMS)
> SetSystemTime(lcString)

> Function StringIt
>     lPara liNum
>     return chr(mod(liNum, 256)) + chr(int(liNum/256))
> endFunc

> Be careful, on my system, XP, this set the clock to 9:53pm because of change
> to daylight saving.

> Andrew R.



> > Hi,

> > somebody knows how to change the date& time of the PC where I am running
> VFP
> > 6.0 application, other that using the command RUN DATE (datetime value) ?

> > I need this ti be done without user intervention and without DOS windows

> > thanks

> > Oscar Taboada



Sun, 04 Sep 2005 22:12:14 GMT  
 how to change the pc date & time?
Yes, I remembered the UTC once I saw your reply.

Andrew R.


Quote:
> Andrew,
> Actually this API call expects a UTC (or Greenwich Mean) DateTime, which

doesn't care about Daylight
Quote:
> savings or even the TimeZone you are in. The OS will automatically adjust

the UTC time given to use
Quote:
> the local DateTime settings. i.e. If I wanted to set my time in Lansing

Mi, USA to 9:10 am this
Quote:
> morning, I'd use 14:10 (GMT).

> Rick




Quote:
> > Use the API SetSystemTime

> > This should do it for you...

> > local lcString, liYear, liMonth, liDOW, liDay, liHour, liMin, liSec,
liMS
> > Declare SetSystemTime ;
> >     in kernel32 ;
> >     string
> > liYear = 2005
> > liMonth = 9
> > liDay = 26
> > liDOW = dow(date(liYear, liMonth, liDay), 2)
> > liHour = 20
> > liMin = 53
> > liSec = 2
> > liMS = 3
> > lcString = StringIt(liYear) + ;
> >     StringIt(liMonth) + ;
> >     StringIt(liDOW) + ;
> >     StringIt(liDay) + ;
> >     StringIt(liHour) + ;
> >     StringIt(liMin) + ;
> >     StringIt(liSec) + ;
> >     StringIt(liMS)
> > SetSystemTime(lcString)

> > Function StringIt
> >     lPara liNum
> >     return chr(mod(liNum, 256)) + chr(int(liNum/256))
> > endFunc

> > Be careful, on my system, XP, this set the clock to 9:53pm because of
change
> > to daylight saving.

> > Andrew R.



> > > Hi,

> > > somebody knows how to change the date& time of the PC where I am
running
> > VFP
> > > 6.0 application, other that using the command RUN DATE (datetime
value) ?

> > > I need this ti be done without user intervention and without DOS
windows

> > > thanks

> > > Oscar Taboada



Mon, 05 Sep 2005 00:00:03 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Date & Time stamping at compile time

2. Change System Time and Date from FP

3. Changing file date/time

4. changing file date/time from within foxpro

5. Date & time

6. modifying system's date & time

7. Saving compile date & time

8. modify file date & time

9. Server's date & time

10. Remote control of client pc system time

11. Size of Windows changes from one PC to another

12. FPD 2.6 & PC Anywhere

 

 
Powered by phpBB® Forum Software