DateTimeExtensionsParseTime Method

Parses textual time input into a DateTime.

Definition

Namespace: InnerDrive.Core
Assembly: InnerDrive.Core (in InnerDrive.Core.dll) Version: 5.3.9666.0
C#
public static DateTime ParseTime(
	this DateTime dateTime,
	string timeText
)

Parameters

dateTime  DateTime
This DateTime.
timeText  String
The time as input by the user.

Return Value

DateTime
A DateTime containing the parsed time.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DateTime. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

timeText may contain any of the following time formats:
TextResult
10:00 AM10:00 AM
10:00 am10:00 AM
10:00 p10:00 PM
10:00p10:00 PM
1000p10:00 PM
10p10:00 PM
100010:00 PM
22:0010:00 PM
220010:00 PM
10ArgumentException
22ArgumentException
22:00 PMArgumentException
22:99ArgumentException

Example

C#
var testDate = new DateTime(2010, 11, 17);
? testDate.ParseTime("6:13 PM");

// Result: 2010-11-17 18:13

Exceptions

ArgumentExceptiontimeText was not a valid time.

See Also