Date format per day, month, year

I am using C #.

I know I can use

ToLongDateString() 

to show something like:

  Friday, February 27, 2009 

What I like to do is show something like:

  February 27, 2009 

I looked around, but did not find what to use for display in this format.

+12
source share
4 answers

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

Try using:

 thisDate1.ToString("MMMM dd, yyyy"); 
+31
source
 var s = yourDateTime.ToString("MMMM dd, yyyy"); 

Check this line in CustomTimeTime format.

+8
source

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 , for example:

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

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

+2
source

Source: https://habr.com/ru/post/954529/


All Articles