如何在asp.net中显示dayofweek [英] how to display dayofweek in asp.net
本文介绍了如何在asp.net中显示dayofweek的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在asp.net中显示星期几
i的日期如下
01/01/2015
以上日期我想在asp.net中显示星期几
为什么我在asp.net中使用c#做什么。
问候,
Narasiman P.
how to display the day of week in asp.net
i have date as follows
01/01/2015
for the above date i want to display the day of the week in asp.net
for that how can i do in asp.net using c#.
Regards,
Narasiman P.
推荐答案
//Use the DateTime class
//The constructor is, new DateTime(int yyyy, int month,int day)
DateTime dateTime = new DateTime(2015, 1, 1);
//You can also parse a string
DateTime dateTimeFromString = DateTime.Parse("01/01/2015");
//To display the day as its full name e.g. Monday
string dayOfWeekLong= dateTime.ToString("dddd");
//To display the day as a shortened name e.g. Mon
string dayOfWeekShort = dateTime.ToString("ddd");
//To display as numeric e.g. 09, 29
string dayOfWeekNumericLong = dateTime.ToString("dd");
请参阅:
http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek%28v=vs.110%29 .aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.datetime.tostring%28v=vs.110%29.aspx [ ^ ] ,
http://msdn.microsoft .com / zh-CN / library / 8kb3ddd4%28v = vs.110%29.aspx [ ^ ](p关注格式说明符'ddd'和'dddd')。
-SA
Please see:
http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.datetime.tostring%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx[^] (pat attention for the format specifiers 'ddd' and 'dddd').
—SA
使用下面的代码。
int dayofweek = Convert.ToInt16(Convert.ToDateTime(01/01/2015)。DayOfWeek);
Use below code.
int dayofweek = Convert.ToInt16(Convert.ToDateTime("01/01/2015").DayOfWeek);
这篇关于如何在asp.net中显示dayofweek的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文