SystemTimeToDateTime (Delphi)
Description
The following code retrieves the current date and time using the Windows GetLocalTime API call, and converts this value to a TDateTime value.
Code
function GetCurrentDateTime: TDateTime;
var
SystemTime: TSystemTime;
begin
GetLocalTime(SystemTime);
Result := SysUtils.SystemTimeToDateTime(SystemTime);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := SysUtils.DateTimeToStr(GetCurrentDateTime);
end;
Uses
- System.SysUtils.SystemTimeToDateTime ( fr | de | ja )