From Clomosy Docs
function StrToTime(const Time string):TclDateTime;
The StrToTime function attempts to convert a time as a string Date into a TclDateTime value. 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)
You may use the current AM and PM value, or the literals 'AM', 'am', 'PM' and 'pm' before or after the time.
Example:
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;
Output:
3PM = 15:00:00 15 = 15:00:00 15:03 = 15:03:00 15:03:45 = 15:03:45