Nate Pet
Nate Pet

Reputation: 46222

Date Format in Day, Month Day, Year

I am using c#.

I know I can use

    ToLongDateString() 

to show something like:

   Friday, February 27, 2009

What I like to do instead is show something like:

  February 27, 2009

I looked around but did not find what to use to display in such a format.

Upvotes: 16

Views: 86380

Answers (4)

p.s.w.g
p.s.w.g

Reputation: 149020

Something like this should work:

new DateTime(2009, 02, 27).ToString("MMMM dd, yyyy") // February 27, 2009

Further Reading

Update In C# 6 and later, you can also use string interpolation, like so:

$"{new DateTime(2009, 02, 27):MMMM dd, yyyy}" // February 27, 2009

Upvotes: 3

Samuel
Samuel

Reputation: 729

Try using this: http://www.csharp-examples.net/string-format-datetime/ The examples are all very readable and easy.

Upvotes: 3

Vajda Endre
Vajda Endre

Reputation: 1570

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

Try to use:

thisDate1.ToString("MMMM dd, yyyy");

Upvotes: 44

King King
King King

Reputation: 63327

var s = yourDateTime.ToString("MMMM dd, yyyy");

Check out this Custom DateTime format string

Upvotes: 10

Related Questions