I am getting this exception:
String was not recognized as a valid DateTime
for this string:
2012-10-03T10:41:22.988401+01:00
using this code:
DateTime.ParseExact(TheStringAbove, "o", CultureInfo.InvariantCulture, DateTimeStyles.None);
I know that the DateTime string is UTC. Is there anything wrong with the code? Thanks.
That string is not UTC – it’s explictly got something saying it’s an hour ahead of UTC! That’s what the +01:00 means. You really need to think about that part carefully.
The reason it’s failing is that doesn’t quite conform to the “o” format:
Note that there are 7 fs there, but you’ve only got 6 decimal places.
2012-10-03T10:41:22.9884010+01:00works fine – but you’ll still need to check whether it actually means what you want it to mean, based on your expectation that this is really UTC.