关于系统时间和星期显示问题..
我想把系统时间和星期显示在label1上,但是显示结果是这样的:2008-4-30 0:00:00 Wednesday我想要的效果是:2008-4-30 星期三.
Label1.Text = Convert.ToString(System.DateTime.Today) + Convert.ToString(System.DateTime.Now.DayOfWeek);//语句应该如何改? --------------------编程问答-------------------- 用日历函数
--------------------编程问答-------------------- DataTime.toShortTime吧,好像是这样的,可以去掉后面的时间,后面那个显示星期我就不大清楚了。 --------------------编程问答-------------------- 我也想了解,谢谢LZ. --------------------编程问答-------------------- 什么 是日历函数 --------------------编程问答--------------------
public static string GetWeekDay(string day)--------------------编程问答-------------------- --------------------编程问答-------------------- DateTime dt = DateTime.Now;
{
string weekday = "";
switch (day)
{
case "Friday":
weekday = "星期五";
break;
case "Monday":
weekday = "星期一";
break;
case "Tuesday":
weekday = "星期二";
break;
case "Wednesday":
weekday = "星期三";
break;
case "Thursday":
weekday = "星期四";
break;
case "Saturday":
weekday = "星期六";
break;
case "Sunday":
weekday = "星期日";
break;
default:
break;
}
return weekday;
}
Label1.Text = Convert.ToString(System.DateTime.Today) + GetWeekDay(DateTime.Now.DayOfWeek.ToString())
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(dt.DayOfWeek);
这个直接获得中文星期几!
--------------------编程问答-------------------- 个人比较
DateTime.Now.ToString("yyyy-M-d dddd");
DateTime.Now.ToString("yyyy-M-d dddd",CultureInfo.CreateSpecificCulture("zh-CN"));
补充:.NET技术 , ASP.NET