Tag Archives: SPWeb

Get name of DayOfWeek from DateTime in current SPWeb

Was working on a method where I wanted to display the name of the selected day in the language of the Site. This could be hard-coded of course, but that is rarely a sustainable solution in the long run. Instead I get the culture from my current SPWeb. The following snippet shows hot to do this:

string dayOfWeekName = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo(web.UICulture.Name));

Edit: My collegue showed me how I can get my current culture from the CultureInfo class instead: