Export (0) Print
Expand All

XmlConvert.ToDateTime Method (String, String)

Converts the String to a DateTime equivalent.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public static DateTime ToDateTime(
	string s,
	string format
)

Parameters

s
Type: System.String

The string to convert.

format
Type: System.String

The format structure to apply to the converted DateTime. Valid formats include "yyyy-MM-ddTHH:mm:sszzzzzz" and its subsets. The string is validated against this format.

Return Value

Type: System.DateTime
A DateTime equivalent of the string.

ExceptionCondition
ArgumentNullException

s is null.

FormatException

s or format is String.Empty

-or-

s does not contain a date and time that corresponds to format.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft