sol
sol

Reputation:

datetime conversion c#

how would you convert this date into c# Datetime object?

Mon Mar 16 14:21:27 +0000 2009

i tried parseexact with format = "ddd MMM dd hh:mm:ss zzzz yyyy" but it didn't work.

what did i do wrong?

Upvotes: 2

Views: 681

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062502

For 24-hour hours, you want HH, not hh:

DateTime when = DateTime.ParseExact("Mon Mar 16 14:21:27 +0000 2009",
    "ddd MMM dd HH:mm:ss zzzz yyyy",
    CultureInfo.InvariantCulture);

Upvotes: 6

Related Questions