From Clomosy Docs
(Created page with " function StrToDateTime(const DateTime string):TclDateTime; The StrToDateTime function attempts to convert a date plus time as a string DateTime 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.<br> The second, time part, separated by a blank from the date must adhere to the format of the LongTimeFormat value, and use the T...") |
ClomosyAdmin (talk | contribs) No edit summary |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
function StrToDateTime(const S: string):TclDateTime; | |||
</div> | |||
The StrToDateTime function attempts to convert a date plus time as a string | |||
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.<br> | |||
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.<br> | 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.<br> | ||
| Line 14: | Line 17: | ||
:The second must be 0..59 (optional) | :The second must be 0..59 (optional) | ||
<b>Example</b><br> | |||
{{#seo:|description=Learn how the StrToDateTime function converts date and time strings into TclDateTime format in Clomosy, with customizable formats and practical examples.}} | |||
myDateTime : TclDateTime; | <pre> | ||
var | |||
myDateTime | myDateTime : TclDateTime; | ||
ShowMessage('23.02.75 12 = '+DateTimeToStr(myDateTime)); | |||
myDateTime | { | ||
ShowMessage('Now = '+DateTimeToStr(myDateTime));<br> | |||
myDateTime = StrToDateTime('23.02.75 12'); | |||
ShowMessage('23.02.75 12 = '+DateTimeToStr(myDateTime)); | |||
myDateTime = Now; | |||
ShowMessage('Now = '+DateTimeToStr(myDateTime)); | |||
} | |||
</pre> | |||
<b>Output:</b><br> | |||
<div class="alert alert-success" role="alert" data-bs-theme="light"> | |||
23.02.75 12 = 23.02.1975 12:00:00<br> | |||
Now = 28.02.2023 14:50:56 | |||
</div> | |||
<h2> See Also </h2> | |||
* [[System_Library#Type_Conversion_Functions | Type Conversion Functions]] | |||
{{#seo:|title=StrToDateTime Using in Clomosy - Clomosy Docs}} | |||
Latest revision as of 15:16, 24 December 2024
function StrToDateTime(const S: string):TclDateTime;
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:
23.02.75 12 = 23.02.1975 12:00:00
Now = 28.02.2023 14:50:56