The Current week dates

Posted by MoezMousavi on Geeks with Blogs See other posts from Geeks with Blogs or by MoezMousavi
Published on Thu, 16 Dec 2010 22:37:40 GMT Indexed on 2010/12/18 17:15 UTC
Read the original article Hit count: 340

Filed under:

The Current week dates

Might be a bit vierd as we normaly not writing a multicultural web site. So not very frequently using CultureInfo however, it is  actully quite good to use it to get the week days.

 

            CultureInfo info = Thread.CurrentThread.CurrentCulture;

            DayOfWeek firstday = info.DateTimeFormat.FirstDayOfWeek;

            DayOfWeek today = info.Calendar.GetDayOfWeek(DateTime.Now);

 

            int diff = today - firstday;

 

            DateTime firstDate = DateTime.Now.AddDays(-diff);

            DateTime lastDate = firstDate.AddDays(6);


 

© Geeks with Blogs or respective owner