From Clomosy Docs

No edit summary
No edit summary
Line 14: Line 14:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
  var
  var
Line 31: Line 31:
   
   
  }
  }
</pre>
<b>Base Syntax</b><br>
<pre>
var
  myTime : TclDateTime;
begin
  myTime := StrToTime('3PM');
  ShowMessage('3PM      = '+TimeToStr(mytime));
  myTime := StrToTime('15');
  ShowMessage('15      = '+TimeToStr(mytime));
  myTime := StrToTime('15:03');
  ShowMessage('15:03    = '+TimeToStr(mytime));
  myTime := StrToTime('15:03:45');
  ShowMessage('15:03:45 = '+TimeToStr(mytime));
end;
</pre>
</pre>



Revision as of 12:59, 13 November 2024

Converts a string to a TclDateTime value.
Call StrToTime to parse a string that specifies a time value. If S does not contain a valid time, StrToTime raises an EConvertError exception.
The time string must adhere to the format of the LongTimeFormat value, and use the TimeSeparator character to separate the hour, minute and second values. The default format is hour:minute:second.milli-seconds, where :

The hour must be 0..23
The minute must be 0..59 (optional)
The second must be 0..59 (optional)
The milli-secs must be 0..999 (optional)


Example

 var
   myTime : TclDateTime;
 
 {
 
   myTime = StrToTime('3PM');
   ShowMessage('3PM      = '+TimeToStr(mytime));
   myTime = StrToTime('15');
   ShowMessage('15       = '+TimeToStr(mytime));
   myTime = StrToTime('15:03');
   ShowMessage('15:03    = '+TimeToStr(mytime));
   myTime = StrToTime('15:03:45');
   ShowMessage('15:03:45 = '+TimeToStr(mytime));
 
 }

Output:

See Also