0

I have the following string that I want to convert to a c# DateTime object:

var dateTimeString = "2020-02-25T00:00:00.000+02:00";

It seems I am not able to parse it with the method below:

var success = DateTime.TryParseExact(dateTimeString , "o", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var startDateTime);

Any advices on how this can be achieved?

Mihaimyh
  • 1,262
  • 1
  • 13
  • 35
  • Check this link [String to DateTime](https://www.c-sharpcorner.com/UploadFile/manas1/string-to-datetime-conversion-in-C-Sharp/) – Marwen Jaffel Mar 06 '20 at 10:50
  • 1
    `var success = DateTime.TryParseExact(dateTimeString, "yyyy-MM-ddTHH:mm:ss.fffzzz", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var startDateTime);` – Matthew Watson Mar 06 '20 at 10:52
  • Thanks, there was a similar answer here https://stackoverflow.com/questions/36313998/how-to-parse-and-generate-datetime-objects-in-iso-8601-format – Mihaimyh Mar 06 '20 at 14:15

0 Answers0