1

when i run the following code:

 DateTime.ParseExact("03-08-2013", "dd-mm-yyyy", null).ToString("dd-MMM-yyyy") 

I get "03-jan-2013"

why does it convert august to january?

2 Answers 2

8

Lowercase mm means minute instead of month, so this should work as desired:

DateTime.ParseExact("03-08-2013", "dd-MM-yyyy", null).ToString("dd-MMM-yyyy") 

Output: 03-Aug-2013

Sign up to request clarification or add additional context in comments.

1 Comment

No, the former means the 8th minute in 2013 and the latter the 8th month.
0

You have "MMM" in the ToString() method, which means you will get a 3-letter month abbreviation. See a helpful article on the topic at http://www.csharp-examples.net/string-format-datetime/.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.