Sitecore 5.1.1 API

DateUtil.ParseTimeSpan Method (String, TimeSpan)

Parses a time string representing a time span.

[Visual Basic]
Overloads Public Shared Function ParseTimeSpan( _
   ByVal time As String, _
   ByVal _default As TimeSpan _
) As TimeSpan
[C#]
public static TimeSpan ParseTimeSpan(
   string time,
   TimeSpan _default
);

Parameters

time
The time in the format "00:00:00" or "00:00:00:00".
_default
Default value to return if time can not be parsed.

Return Value

A TimeSpan class representing the Itime string.

Remarks

Format must be 00:00:00 representing hours, minutes and seconds. A fourth optional part may be added, representing milliseconds (ie. 00:00:00:00)

Example

The following example returns the TimeSpan eqivalent of the time string.

  string timeString = "13:45:00";
  TimeSpan timeSpan = DateUtil.ParseTimeSpan(timeString);

See Also

DateUtil Class | Sitecore Namespace | DateUtil.ParseTimeSpan Overload List