tags:

views:

197

answers:

6

Hello Im using C# 3.5,

I have this : Datetime.Now(); or 23/10/2009
I want this : Friday

for local datetime (GMT-5) and using gregorian calendar.

Thanks

+9  A: 
//default locale
System.DateTime.Now.DayOfWeek.ToString();
//localized version
System.DateTime.Now.DayOfWeek.ToString("dddd");

To make the answer more complete:

brendan
I wouldn't use the ToString. If you need it for comparisons or storage, just use the enum value. Otherwise, using the dddd format specifier as in Fredrik's answer is better for localization.
technophile
+2  A: 

DateTime.Now.DayOfWeek quite easy to guess actually.

for any given date:

   DateTime dt = //....
   DayOfWeek dow = dt.DayOfWeek; //enum
   string str = dow.ToString(); //string
Itay
+1  A: 

You're looking for the DayOfWeek property.

Here's the msdn article.

Joseph
+1  A: 
DateTime now = DateTime.Now
string s = now.DayOfWeek.ToString();
Charles Bretana
+8  A: 

If you want to know the day of the week for your code to do something with it, DateTime.Now.DayOfWeek will do the job.

If you want to display the day of week to the user, DateTime.Now.ToString("dddd") will give you the localized day name, according to the current culture (MSDN info on the "dddd" format string).

Fredrik Mörk
+1 for the dddd format answer.
technophile
A: 

DateTime.Now.DayOfWeek

ManojTrek