Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
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


Type: System.String

The string to convert.

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.


s is null.


s or format is String.Empty


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

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8
© 2015 Microsoft