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 }
That’s exactly the chunk of code I was looking for! Thanks!