本周几与当前的年月日

      简单的获取年月日与星期几   

             string week=string.empty;
                int day = Convert.ToInt32(DateTime.Now.DayOfWeek);
                switch (day)
                {
                    case 1:
                        week = "星期一";
                        break;
                    case 2:
                        week = "星期二";
                        break;
                    case 3:
                        week = "星期三";
                        break;
                    case 4:
                        week = "星期四";
                        break;
                    case 5:
                        week = "星期五";
                        break;
                    case 6:
                        week = "星期六";
                        break;
                    default:
                        week = "星期日";
                        break;
                }

年:DateTime.Now.Year.ToString()

月:DateTime.Now.Month.ToString()

日:DateTime.Now.Day.ToString()

你可能感兴趣的:(本周几与当前的年月日)