- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Getting the time and date in Universal Time

Question:

How can I get the time and date in Universal Time?

Answer:

Use the WIndows API function GetSystemTime.

Example:

procedure TForm1.Button1Click(Sender: TObject);
var
  lt : TSYSTEMTIME;
  st : TSYSTEMTIME;
begin
  GetLocalTime(lt);
  GetSystemTime(st);
  Memo1.Lines.Add('LocalTime = ' +
                  IntToStr(lt.wmonth) + '/' +
                  IntToStr(lt.wDay) +  '/' +
                  IntToStr(lt.wYear) + ' ' +
                  IntToStr(lt.wHour) +  ':' +
                  IntToStr(lt.wMinute) +  ':' +
                  IntToStr(lt.wSecond));
  Memo1.Lines.Add('UTCTime = ' +
                  IntToStr(st.wmonth) + '/' +
                  IntToStr(st.wDay) +  '/' +
                  IntToStr(st.wYear) + ' ' +
                  IntToStr(st.wHour) +  ':' +
                  IntToStr(st.wMinute) +  ':' +
                  IntToStr(st.wSecond));
end;




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile