Mega Code Archive

 
Categories / C# / Date Time
 

Tries to converts a string to DateTimeOffset(String with date and offset )

using System; using System.Globalization; public class Example {    public static void Main()    {         DateTimeOffset parsedDate;         string dateString;                           // String with date and offset          dateString = "05/01/2008 +7:00";         if (DateTimeOffset.TryParse(dateString, out parsedDate))            Console.WriteLine("{0} was converted to to {1}.", dateString, parsedDate);    } }