From Clomosy Docs

No edit summary
No edit summary
Line 18: Line 18:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
  var
  var
Line 32: Line 32:
   
   
  }
  }
</pre>
<b>Base Syntax</b><br>
<pre>
var
  myDateTime : TclDateTime;
begin
  myDateTime := StrToDateTime('23.02.75  12');
  ShowMessage('23.02.75  12      = '+DateTimeToStr(myDateTime));
  myDateTime := Now;
  ShowMessage('Now  = '+DateTimeToStr(myDateTime));
end;
</pre>
</pre>



Revision as of 12:56, 13 November 2024


The StrToDateTime function attempts to convert a date plus time as a string S into a TclDateTime value. The first, date part of the string must adhere to the format of the ShortDateFormat value, and use the DateSeparator character to separate the day, month and year values.

The second, time part, separated by a blank from the date 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 day.month.year hour:minute:second, where :

The day must be 1..31 (depending on month/year)
The month must be 1..12
The year must be 0..9999 (optional)
The hour must be 0..23
The minute must be 0..59 (optional)
The second must be 0..59 (optional)

Example

 var
   myDateTime : TclDateTime;
 
 {
 
   myDateTime = StrToDateTime('23.02.75   12');
   ShowMessage('23.02.75   12      = '+DateTimeToStr(myDateTime));
 
   myDateTime = Now;
   ShowMessage('Now   = '+DateTimeToStr(myDateTime));
 
 }

Output:

See Also