Converts a string to a date and time value.
[Visual Basic] Public Shared Function ToDateTime( _ ByVal value As String _ ) As DateTime [C#] public static DateTime ToDateTime( string value ); [C++] public: static DateTime ToDateTime( String* value ); [JScript] public static function ToDateTime( value : String ) : DateTime;
The date and time value represented by the string.
Exception Type | Condition |
---|---|
XmlException | If value is null or a reference to a string that does not contain a valid date and time value. |
The value parameter must be a non-null reference to a string that contains a well-formed date and time value. The string must be of the form YYYY-MM-DDThh:mm:ss.sssssss, where YYYY is the year (0001-9999), MM is the month (01-12), DD is the day (01-31), T is the literal character 'T', hh is the hour (00-23), mm is the minute (00-59), and ss.sssssss is the second (00-59), optionally followed by a decimal point and a fractional part.
The date and time string may optionally be followed by a time zone indicator. The time zone indicator consists either of the letter 'Z' (indicating GMT), or of a '+' or '-' followed by a time difference the form hh:mm. In the latter case, the indicated time difference is added to or subtracted from the resulting value.
XmlString Class | XmlString Members | System.Xml Namespace | FromDateTime