Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the complete month name in English

Tags:

c#

datetime

I use DateTime.Now.ToString("MMMM") in order to get the current month's full name. It works well, but I get it in Hebrew.
Is there an option to control the output language?
I need it to be English.

like image 728
benams Avatar asked Jan 03 '12 11:01

benams


People also ask

How to get full month name 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"); Step 4: This string contains the name of the month.

How to get month name from date in linq?

Write simple select query and use DateTime structure . ToString("MMMM") method to get month name.

How do I get a short month name?

To list short months, use the getShortMonths() from the DateFormatSymbols class in Java. DateFormatSymbols is a class for encapsulating localizable date-time formatting data.

How to convert int month to string month in c#?

DateTime dt = DateTime. Now; Console. WriteLine( dt. ToString( "MMMM" ) );


2 Answers

You can pass a CultureInfo object as an argument DateTime.ToString():

CultureInfo ci = new CultureInfo("en-US");
var month = DateTime.Now.ToString("MMMM", ci);

// alternatively you can use CultureInfo.InvariantCulture:
var month = DateTime.Now.ToString("MMMM", CultureInfo.InvariantCulture);
like image 128
Dennis Traub Avatar answered Sep 28 '22 03:09

Dennis Traub


Pass in the culture in which you want the name formatted. Like this:

DateTime.Now.ToString("MMMM", new CultureInfo("en-GB"));
like image 24
driis Avatar answered Sep 28 '22 03:09

driis