Converting a date format
-
Hi, I have date data supplied as a string in the following format... "Mon Sep 9 00:00:00 UTC 0100 2013". Firstly, what is this format? Secondly, how can I use C# to convert it and stire it in a DateTime variable? I've tried... DateTime dt = Convert.ToDateTime("Mon Sep 9 00:00:00 UTC 0100 2013"); but this blows up :( Many Thanks.
-
Hi, I have date data supplied as a string in the following format... "Mon Sep 9 00:00:00 UTC 0100 2013". Firstly, what is this format? Secondly, how can I use C# to convert it and stire it in a DateTime variable? I've tried... DateTime dt = Convert.ToDateTime("Mon Sep 9 00:00:00 UTC 0100 2013"); but this blows up :( Many Thanks.
-
Hi, I have date data supplied as a string in the following format... "Mon Sep 9 00:00:00 UTC 0100 2013". Firstly, what is this format? Secondly, how can I use C# to convert it and stire it in a DateTime variable? I've tried... DateTime dt = Convert.ToDateTime("Mon Sep 9 00:00:00 UTC 0100 2013"); but this blows up :( Many Thanks.
See here[^] it lists, d, D, f, F, g, G, M, m, O, o, R, r, S, t, T, u, U, y, Y as valid format strings, and below the table it says : Any other single character unknown specifier. Throws a run-time FormatException. In my case it says: String was not recognized as a valid DateTime. try to remove the K specification along with the 0100...
-
See here[^] it lists, d, D, f, F, g, G, M, m, O, o, R, r, S, t, T, u, U, y, Y as valid format strings, and below the table it says : Any other single character unknown specifier. Throws a run-time FormatException. In my case it says: String was not recognized as a valid DateTime. try to remove the K specification along with the 0100...
Thanks for the reply. I can't get it to work as a UTC. If I change it to UTC+ by adding the plus sign in to replace the space directly after the UTC on the fly then parse I can get it to work... string strStart = "Mon Sep 9 00:00:00 UTC 0100 2013"; strStart = strStart.Replace("UTC ", "UTC+"); DateTime dtStart = DateTime.ParseExact(strStart, "ddd MMM d HH:mm:ss UTCzzzz yyyy", CultureInfo.InvariantCulture); This works!
-
Thanks for the reply. I can't get it to work as a UTC. If I change it to UTC+ by adding the plus sign in to replace the space directly after the UTC on the fly then parse I can get it to work... string strStart = "Mon Sep 9 00:00:00 UTC 0100 2013"; strStart = strStart.Replace("UTC ", "UTC+"); DateTime dtStart = DateTime.ParseExact(strStart, "ddd MMM d HH:mm:ss UTCzzzz yyyy", CultureInfo.InvariantCulture); This works!
:thumbsup: