Главная страница | назад





Article #16157: Getting the time and date in Universal Time

 Question and Answer Database

FAQ1157D.txt   Getting the time and date in Universal Time
Category   :Windows API
Platform    :All
Product    :All 32 bit  

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;



7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99