I'm building an app which needs to function depending on the current day. I've googled but returned with no results. Is there any function in C# that will return the current day depending on system time? Any help would be appreciated.

有帮助吗?

解决方案 2

var dateTime = DateTime.Now.Day;

More info is found in the actual documentation from MSDN

其他提示

Have you tried DateTime.Now.Day? Sorry but I can´t comment yet.

@edit

For more information about the DateTime class, take a look at this link: http://msdn.microsoft.com/en-us/library/system.datetime.aspx

This is what I use to display the date as: MM/DD/YYYY

string fullDate;
string date = DateTime.Today.Day.ToString();
string month = DateTime.Today.Month.ToString();
string year = DateTime.Today.Year.ToString();

fullDate = month + "/" + date + "/" + year;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top