ToDateTime Method (String, String)
Collapse the table of content
Expand the table of content

XmlConvert.ToDateTime Method (String, String)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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
NullReferenceException

s is null.

FormatException

s or format is String.Empty

-or-

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

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft