DateTime format in C #

Possible duplicate:
C # date format

I want to show the date in May 16, 2011 format. I used the format String.Format("{0:D}" , with which I received the output as Monday, May 16, 2011 So please tell me how I can show the date in the following format May 16, 2011 Thanks in advance

+1
source share
6 answers
 "{0:MMMM d, yyyy}" 

Here is the documentation.

Custom Date and Time Format Strings

+6
source
 DateTime dt = DateTime.Now; String.Format("{0:MMMM d, yyyy}", dt); 

Should it be a trick?

EDIT: Here are some examples! http://www.csharp-examples.net/string-format-datetime/

+2
source
 DateTime.Now.ToString("MMM dd, yyyy"); 
+1
source

try it

  String.Format("{0:MMMM dd, yyyy}", someDate) 
0
source

If you use D for the date format, the format will be selected from the regional settings on the machine’s control panel. You can change the date format of the machine on which the software is running. (Or manual format code).

0
source

It seems that the Standard date and time string matches your desired format, so you need to build a Custom date and time format string

This should do the trick:

 string.Format("{0:MMMM dd, yyyy}", value) 

Or alternatively

 value.ToString("MMMM dd, yyyy") 
  • MMMM is the full name of the month, for example. June (en-US)
  • dd - Day of the month, from 01 to 31
  • yyyy - year as a four-digit number.
0
source

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


All Articles