All Delphi

Everything You Want To Know From VCL, Tips To Snippet All Everything About Delphi And CodeGear Related

    Search

  • Sponsors

  • Spottt
    Spottt

GMT Time To Local Time

3rd April 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;
Rate this:
2.7

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>