From Clomosy Docs

No edit summary
No edit summary
 
(2 intermediate revisions by 2 users not shown)
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>


Line 61: Line 43:
<h2> See Also </h2>
<h2> See Also </h2>
* [[System_Library#Type_Conversion_Functions | Type Conversion Functions]]
* [[System_Library#Type_Conversion_Functions | Type Conversion Functions]]
{{#seo:|title=StrToTime Using in Clomosy - Clomosy Docs}}
{{#seo:|description=Explore StrToTime on Clomosy! Learn how to convert string representations of time into date-time objects in your applications.}}

Latest revision as of 13:30, 24 December 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