Blog Of Sem: DELPHI TIME

DELPHI TIME

procedure TForm1.Timer1Timer(Sender: TObject);
var
DateTime : TDateTime;
Timestr,Timestr2 : string;
Datestr : string;

begin
DateTime := Time; // store the current date and time
Timestr2 := TimeToStr(DateTime); // convert the time into a string
Caption := Timestr2; // display the time on the form's caption
{Note This could have been done with the following line of code:
Caption := TimeToStr(Time); }


Timestr := formatDateTime('hh:mm', StrToDateTime(Timestr2));//format the time }
Label1.caption := DateToStr(Date);
Label2.caption := Timestr;
Form1.Caption := Caption; //puts time on Form Bar
// Label2.caption := TimeToStr(Time); //alternative method


end;

No comments:

Post a Comment