Description |
The TimeToStr function converts a TDateTime value Time into a formatted time string.
The time is formatted using the LongTimeFormat value, which in turn uses the TimeSeparator value.
Version 2 of this function is for use within threads. You furnish the FormatSettings record before invoking the call. It takes a local copy of global formatting variables that make the routine thread safe.
|
|
Related commands |
|
|
|
Example code : Converting a time value to a string |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses SysUtils, // Unit containing the TimeToStr command Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
myTime : TDateTime;
begin
myTime := StrToTime('15:22:35');
ShowMessage('myTime = '+TimeToStr(myTime));
end; end.
|
Hide full unit code |
myTime = 15:22:35
|
|