Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTime Convert from int to Month Name in C#, Silverlight

Tags:

I am trying to print out the name of the month not the integer value of each month. (for example if the date is 2/2/2002, I would like the "month" to read out "February" instead of "2."

I am pulling in the system.DateTime.now to get the current month. When I try to print out the current month on the form, it just puts the correlating integer value for the month, whereas I would like to have the Month Name.

I know this can be done using switch-case or if statements to individually convert the numbers into word values, but I was just wondering if there was a simple, built-in conversion command that will automatically tell the application to print out the month's name instead of it's correlating integer value.

I am programming in the Visual Studio 2010 environment using C#-4.0, Silverlight-4.0.

like image 697
AmbiguousX Avatar asked Aug 03 '10 20:08

AmbiguousX


People also ask

How to get full month name from DateTime in c#?

// to get the Abbreviated month name string month_name = date. ToString("MMM"); // to get the full month name string month_name = date. ToString("MMMM");

How can get month name from month number in SQL?

1. To convert month number to month name we have to use a function MONTHNAME(), this function takes date column or a date as a string and returns the Month name corresponding to the month number.

How do you convert a number to a month in Python?

Method #1 : Using strftime() + %B In this, we use strftime() which converts date object to a string using a format, and by providing %B, it's enforced to just return a Month Name.

How do you get the month name in flutter?

In the Flutter Event Calendar, you can get the month and year of month view by using onViewChanged callback of calendar. Using onViewChanged callback you can get the month and year of the month view using visibleDates property of ViewChangedDetails args.


1 Answers

Try DateTime.Now.ToString("MMMM")

See MSDN: Custom Date and Time Format Strings for other format strings.

like image 127
Justin Avatar answered Sep 22 '22 06:09

Justin