Today, there was a requirement to show the month name in a text box. There are two forms that we have to show, depending on the user choice. The choices being the full name of the month as well as short name. Something similar to that of “October” for full name and “Oct” for short name.
We know that we get the month number from DateTime object. This DateTime object has many properties that are directly associated to show the different parameters of Date and Time of the day. But now, for our requirement, you can get the full name of the month with the help of the Globalization object. That is too complicated.
The simple method is to use the ToString() with the format that is required.
DateTime.Now.ToString("MMMM") Give you full name
DateTime.Now.ToString("MMM") returns you short name as required
How is this?