Posted in C#.Net

Displaying the month name in C#

System.DateTime.Now.Month  returns the integer value of the month.
—————————————————————————————————–

        System.Globalization.
            CultureInfo.CurrentCulture.DateTimeFormat.
            GetMonthName(System.DateTime.Now.Month)    displays the month name.

—————————————————————————————————–

lblDateTime.Text = “Today’s date is ” +
            System.DateTime.Now.DayOfWeek.ToString() + “, ” +
            System.Globalization.
            CultureInfo.CurrentCulture.DateTimeFormat.
            GetMonthName(System.DateTime.Now.Month) + ” ” +
            System.DateTime.Now.Day.ToString() + “, ” +
            System.DateTime.Now.Year.ToString() + “.”;

The result of above line is Today’s date is Tuesday, June 21, 2011.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s