GMT Time To Local Time

by admin on April 3, 2008

Hi, have you guys , ever involved in creating application that will be used in different country or event different time zone ? well in most case ..all data that have DateTime value will be much saver if we saved it on GMT time basis.. and there for when we want to display the data to our GUI need to be converted into localize timed,bellow is some of the snippet that we can used ..

function GMTToLocalTime(GMTTime: TDateTime): TDateTime;
var
  GMTST: Windows.TSystemTime;
  LocalST: Windows.TSystemTime;
begin
   SysUtils.DateTimeToSystemTime(GMTTime, GMTST);
   SysUtils.Win32Check(Windows.SystemTimeToTzSpecificLocalTime(nil, GMTST, LocalST));
   Result := SysUtils.SystemTimeToDateTime(LocalST);
end;

{ 1 comment… read it below or add one }

Tim October 1, 2010 at 2:25 am

That’s exactly the chunk of code I was looking for! Thanks!

Reply

Leave a Comment

Previous post:

Next post: