Get the day of the week, in the right language

I’m working on an app that at some point will need to work in multiple languages and needed to display the day of the week to the user. I started with:

string label = DateTime.Today.DayOfWeek.ToString()

But that give me the name of the enumeration, which is of course in English. In order to get the name based on the current language setting I needed the following code:


var culture = System.Globalization.CultureInfo.CurrentCulture;
string label = culture.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek);

Happy coding!

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s