Tag Archives: SPWeb

No more ‘using’ statements! WithWeb-Pattern.

http://sharepointkunskap.wordpress.com/2011/09/15/withweb-pattern-of-jonas-nilsson/

Advertisements

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:

System.Globalization.CultureInfo.CurrentCulture