当前位置:编程学习 > C#/ASP.NET >>

请问大虾一个时间显示问题...

我想用一个lable控件显示时间:

格式为:2008年12月15日 星期一  这样的


不知道CS代码怎么写..

请大虾帮忙..



谢谢!~! --------------------编程问答-------------------- 好像是个完整日期!格式化一下即可! --------------------编程问答-------------------- DateTime dt = DateTime.Today();
            dt.DayOfWeek();
            string week;
            switch (dt.DayOfWeek)
            {
                case DayOfWeek.Monday:
                    week = "星期一";
                    break;
                case DayOfWeek.Tuesday:
                    week = "星期二";
                    break;
                case DayOfWeek.Wednesday:
                    week = "星期三";
                    break;
                case DayOfWeek.Thursday:
                    week = "星期四";
                    break;
                case DayOfWeek.Friday:
                    week = "星期五";
                    break;
                case DayOfWeek.Saturday:
                    week = "星期六";
                    break;
                case DayOfWeek.Sunday:
                    week = "星期日";
                    break;
                default:
                    break;
            }
            Lalbe1.Text = dt.ToString("yyyy年MM月dd日") + " " + week; --------------------编程问答-------------------- 第二行 dt.DayOfWeek();  这一句没有用,我多写了一行。 --------------------编程问答--------------------
引用 2 楼 todaywlq 的回复:
DateTime dt = DateTime.Today(); 
            dt.DayOfWeek(); 
            string week; 
            switch (dt.DayOfWeek) 
            { 
                case DayOfWeek.Monday: 
                    week = "星期一"; 
                    break; 
                case DayOfWeek.Tuesday: 
                    week = "星期二"; 
                    break; 
                case DayOfWeek.Wedne…
--------------------编程问答-------------------- 谢谢大家!!~ --------------------编程问答-------------------- 2楼UP --------------------编程问答-------------------- 来个简单的


 string s=DateTime.Now.ToString("yyyy年MM月dd日 hh:mm:ss 星期ddd");
        Response.Write(s);
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,