NoWar
NoWar

Reputation: 37633

Get DateTime.DayOfWeek for specific culture

Is it possible to get DayOfWeek for a specific culture?

Any clue?

Thank you!!!

Upvotes: 2

Views: 4713

Answers (4)

MMK
MMK

Reputation: 3721

Try the following:

DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("ar-EG"))

For details, MSDN

Upvotes: 6

Riccardo
Riccardo

Reputation: 1520

string myTime = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("it-IT"));

the example use italian culture code, for a list of available culture codes check out this

Upvotes: 1

Tim Schmelter
Tim Schmelter

Reputation: 460098

Do you want to get the day name of today's DayOfWeek in a given culture?

DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("de-DE"))

("Montag" for germany)

Upvotes: 3

dtb
dtb

Reputation: 217273

You can get the localized names of days from the DateTimeFormatInfo.DayNames Property:

var cultureInfo = new CultureInfo("de-DE");
var dateTimeInfo = cultureInfo.DateTimeFormat;
var dayNames = dateTimeInfo.DayNames;
var result = dayNames[(int)DayOfWeek.Wednesday];
// result == "Mittwoch"

Upvotes: 2

Related Questions