Parsing a date / time string in a specific format
3 answers
You can see more information about custom date formats in C # here:
However, here is some code to get you started.
First, define the correct format string that you expect. and then useParseExact
static void Main(string[] args)
{
var date = "28/Jul/2015:01:02:36 -0500";
var formatstring = "dd/MMM/yyyy:HH:mm:ss K";
var d = DateTime.ParseExact(date, formatstring, null);
Console.WriteLine(d);
Console.ReadLine();
}
Hope this helps!
+5
source to share