Link to home
Start Free TrialLog in
Avatar of lpd
lpd

asked on

Set new sysdate from delphi 2.0, 3.0

I need a procedure that can change the system date and time

I use both win95 and NT
Avatar of ronit051397
ronit051397

Are you using NT or 95?
Avatar of lpd

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of JimBob091197
JimBob091197

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you

it works fine but, a have a small problem with timezones. the procedure that you wrote will set the time as if the timezone was GMT. Do you know how to see that timezone that currently is in use ?

Avatar of lpd

ASKER

Ah, that would explain why I need to -2 for hour!!

To get current timezone bias, use GetTimeZoneInformation.

E.g.
var
  MinutesDiff: Integer;
  TZInfo: TTimeZoneInformation;
begin
  GetTimeZoneInformation(TZInfo);
  MinutesDiff := TZInfo.Bias;
end;

In my case, MinutesDiff = -120 (i.e. 2 hrs behind).

JB
P.S.  If you don't want do the TimeZone thing, use SetLocalTime instead of SetSystemTime.

JB
Thanks agin