Skip to content

TryStrToTime

Try to convert a string with a time indication to a TDateTime value

Declaration

Source position: datih.inc line 168

  function TryStrToTime(const S: ShortString; out Value: TDateTime)
                        : Boolean;
  function TryStrToTime(const S: AnsiString; out Value: TDateTime)
                        : Boolean;
  function TryStrToTime(const S: ShortString; out Value: TDateTime; 
                       separator: Char) : Boolean;
  function TryStrToTime(const S: AnsiString; out Value: TDateTime; 
                       separator: Char) : Boolean;
  function TryStrToTime(const S: string; out Value: TDateTime; 
                       const FormatSettings: TFormatSettings) : Boolean;

Description

TryStrToTime tries to convert the string S to a TDateTime time value, and stores the result in Value. The time must consist of 1 to 4 digits, separated by the TimeSeparator character. If two numbers are given, they are supposed to form the hour and minutes.

The function returns True if the string contained a valid time indication, False otherwise.

See also

Name Description
DateToStr Converts a TDateTime value to a date string with a predefined format.
StrToDate Convert a date string to a TDateTime value.
StrToTime Convert a time string to a TDateTime value.
TimeToStr Convert a TDateTime time to a string using a predefined format.
TryStrToDate Try to convert a string with a date indication to a TDateTime value
TryStrToDateTime Try to convert a string with date/time indication to a TDateTime value