Sitecore 5.1.1 API

DateUtil.IsoDateToDateTime Method (String, DateTime)

Converts an ISO formatted date/time string to a DateTime class.

[Visual Basic]
Overloads Public Shared Function IsoDateToDateTime( _
   ByVal isoDate As String, _
   ByVal _default As Date _
) As Date
[C#]
public static DateTime IsoDateToDateTime(
   string isoDate,
   DateTime _default
);

Parameters

isoDate
An ISO formatted date/time string.
_default
Default value to use if isoDate can not be converted to a date/time.

Return Value

The DateTime class equivalent of the date/time string. If the date/time is not valid, DateTime.MinValue is returned.

Remarks

The date/time string is formatted as "yyyyMMddTHHmmss".

Example

The following example converts an ISO formatted date/time string to a DateTime class.

  string isoNow = DateUtil.IsoNow;
  DateTime now = DateUtil.IsoDateToDateTime(isoNow);

See Also

DateUtil Class | Sitecore Namespace | DateUtil.IsoDateToDateTime Overload List