Amit
Amit

Reputation: 3478

Date formats in C#

I need to display dates in Month date, year (Ex: January 20, 2010).

Any suggestion ?

Upvotes: 4

Views: 182

Answers (4)

Johnny
Johnny

Reputation: 1575

Try DateField.ToString("MMMM-dd-yyyy");

Upvotes: 0

Mitch Wheat
Mitch Wheat

Reputation: 300549

Use String.Format(formatspecifier)

Custom Numeric Format Strings

Upvotes: 0

Dean Harding
Dean Harding

Reputation: 72658

var dt = new DateTime(2010, 20, 1);
string s = dt.ToString("MMMM dd, yyyy");

See here for more info.

Upvotes: 6

Alastair Pitts
Alastair Pitts

Reputation: 19601

See this MSDN document. Contains all the information required for custom date and time format strings.

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

Probably worth bookmarking it as well, I always find myself coming back to it.

Upvotes: 0

Related Questions