unit SysUtilsTimeToStr;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: SysUtilsTimeToStr
// Routine: SysUtils.Time
// Routine: SysUtils.TimeToStr

// BeginCode
{
This procedure displays the current time in the form's
caption every time the Timer's OnClick event fires, based upon
the Interval Property (default: 1000 = 1 sec)
}
procedure TForm1.Timer1Timer(Sender: TObject);
var
  DateTime : TDateTime;
  str : string;
begin
  DateTime := Time;  // store the current date and time
  str := TimeToStr(DateTime); // convert the time into a string
  Caption := str;  // display the time on the form's caption
  { Note This could have been done with the following line of code:
    Caption := TimeToStr(Time); }
end;
// EndCode
// EndExample: SysUtilsTimeToStr
end.
