Re: timezone?

Posted by Phil Birell p16812 on December 01, 2009

In Reply to timezone? posted by andre on October 07, 2009

: Since the Now(); function returns the LOCAL time, and I need UTC, I am trying to obtain the current timezone using this code:

: GetTimeZoneInformation(tz);
: ShowMessage(IntToStr(tz.StandardBias)); // 0
: ShowMessage(IntToStr(tz.DaylightBias)); // -60

:
: my timezone is set to GMT+1 (Amsterdam, Berlin, Bern, Rome.....)
: so, there values don't seem to be correct.
-----------------------

Try the following code, it should show 60 in november (no "daylight saving") for zone GMT+1:

procedure TForm1.Button1Click(Sender: TObject);
var
tz : TTimeZoneInformation;

begin
case GetTimeZoneInformation(tz) of
TIME_ZONE_ID_STANDARD:
ShowMessage('Standard Time: offset in minutes is ' +
IntToStr(-(tz.StandardBias + tz.Bias)));
TIME_ZONE_ID_DAYLIGHT:
ShowMessage('Daylight Saving Time: offset in minutes is ' +
IntToStr(-(tz.StandardBias + tz.Bias)));
else
ShowMessage('Unknown Time Zone ID');
end;
end;


Related articles

       

Follow Ups