Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

DayOfWeek not influenced by Culture

Modified: 2008/12/18 18:02 by jim - Categorized as: ASP.NET
While trying to get the day of the week in Dutch I stumbled upon a nice quirk:

Try the next piece of code and notice: dag = in Dutch, dow = in English.

System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("nl-NL", false);
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("nl-NL", false);

DateTime dt = DateTime.Now;
string dow = dt.ToString("dddd");
string dag = dt.DayOfWeek.ToString();

 © Evident Interactive BV