Reputation: 8237
trying to parse this as datetime :
2011.03.13-21:15:04+511.0597
using
Console.WriteLine(DateTime.ParseExact("2011.03.13-21:15:04+511.0597",
"yyyy.MM.dd-hh:mm:ss+ttt.tttt",
CultureInfo.CreateSpecificCulture("en-US")).ToString());
but it says unrecognized string.
any idea what im doing wrong ?
Upvotes: 2
Views: 235
Reputation: 34200
Not sure exactly, but if I trim off everything after the seconds it parses fine. The "tt"
part of a custom format is for AM/PM marker, which is one likely target... I guess you mean fff
which is the fractional part of the seconds...
Another one is that you have lower-case "hh"
which is for 12-hour clock only - your string has 21
as the hour portion, which would require upper-case HH
in your format...
You also can't split two groups of digits with any character, as you have with ttt.tttt
. The closest working code I can get to your sample is this:
DateTime.ParseExact("2011.03.13-21:15:04+511", "yyyy.MM.dd-HH:mm:ss+fff", CultureInfo.CreateSpecificCulture("en-US"))
Upvotes: 3