EncodeTime (Delphi)

From RAD Studio Code Examples

Description

This example uses four edit controls, a label, and a button on a form. When the button is clicked, the hour, minute, second, and millisecond specified in the edit controls are encoded in a TDateTime value using EncodeTime. Then the TDateTime object is converted to a string with TimeToStr and displayed in the label.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  MyDate: TDateTime;
begin
  MyDate := SysUtils.EncodeTime(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text), StrToInt(Edit4.Text));
  Label1.Caption := TimeToStr(MyDate);
end;

Uses