What is the proper way to get the complete name of month of a DateTime
object?
e.g. January
, December
.
I am currently usi
DateTime birthDate = new DateTime(1981, 8, 9);
Console.WriteLine ("I was born on the {0}. of {1}, {2}.", birthDate.Day, birthDate.ToString("MMMM"), birthDate.Year);
/* The above code will say:
"I was born on the 9. of august, 1981."
"dd" converts to the day (01 thru 31).
"ffffd" converts to 3-letter name of day (e.g. mon).
"ffffdd" converts to full name of day (e.g. monday).
"MMM" converts to 3-letter name of month (e.g. aug).
"MMMM" converts to full name of month (e.g. august).
"yyyy" converts to year.
*/
Use the "MMMM" custom format specifier:
DateTime.Now.ToString("MMMM");
It's
DateTime.Now.ToString("MMMM");
With 4 M
s.