-2

How to parse a this datetime string in c#

 Mar 25 2014 10:15:58:757AM

I have tried this, but not working.

DateTime val = DateTime.ParseExact(dateTimeStringValue, "MMM dd yyyy hh:mm:ss:fffTT", CultureInfo.InvariantCulture);
SatheeshN
  • 493
  • 4
  • 5

1 Answers1

2

Custom date and time format strings are case sensitive.

That's why you should use tt instead of TT.

DateTime.ParseExact("Mar 25 2014 10:15:58:757AM", 
                    "MMM dd yyyy hh:mm:ss:ffftt", 
                    CultureInfo.InvariantCulture);
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364