Hey guys, I have to compare 2 timestamps, but before I do that, I have to put it in a forma C# likes. the time stamp comes in this format 2013-09-27 15:09:02.085 and doing this
string date = "2013-09-27 15:09:02.085 ";
DateTime dt = Convert.ToDateTime(date);
Console.WriteLine("Year: {0}, Month: {1}, Day: {2}, Hour:{3}, Minutes:{4},Sec:{5},", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second);
crashes the program, because C# wants it in this format
string date = "2013/09/27 15:09:02.085 ";
DateTime dt = Convert.ToDateTime(date);
Console.WriteLine("Year: {0}, Month: {1}, Day: {2}, Hour:{3}, Minutes:{4},Sec:{5},", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second);
Now I know how to get it into that format, but it requires a lot of ugly reformatting through code. So my question is , is there an easier way of getting it into this format 2013/09/27 15:09:02.085 cleanly and with as little code as possible?.
Thank you