Alex Rivera | Logout

C# DateTime ToString("MM-dd-yyyy") returns funny day values

Asked 2009-09-11T14:46:43.713
11

I have the following code in the codebehind file of an ASP.Net page

txtStartDate.Text = DateTime.Today.ToString("MM-dd-yyyy");

Which I expect to return "09-11-2009". However, when I run the page on the development server, I see "09-00-2009" in the text box. I can't see any reason for this, so I'm clearly missing something. Anyone have a clue?

Edit
Report

1 Answer

4

Try something like this:

DateTime.Today.ToString("MM-dd-yyyy", CultureInfo.CreateSpecificCulture("en-US"))
answered 2009-09-11T15:17:55.587

Your Answer