Tries to converts a string to DateTimeOffset(String with date, time with AM/PM designator, and offset)
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
DateTimeOffset parsedDate;
string dateString;
// String with date, time with AM/PM designator, and offset
dateString = "5/1/2008 10:00 AM -07:00";
if (DateTimeOffset.TryParse(dateString, out parsedDate))
Console.WriteLine("{0} was converted to to {1}.", dateString, parsedDate);
}
}
Related examples in the same category