怎么获得本周周一的时间啊?求高手
比如今天18号,星期五,我要获得周一的时间就是14号,怎么得到?是不是要循环?求高手
------解决方案--------------------
DateTime datetime = Convert.ToDateTime(year + "-" + month + "-" + "1");
// MessageBox.Show(datetime.DayOfWeek + "");
int week = 0;
switch (datetime.DayOfWeek)
{
case DayOfWeek.Friday:
week = 5;
break;
case DayOfWeek.Monday:
week = 1;
break;
case DayOfWeek.Saturday:
week = 6;
break;
case DayOfWeek.Sunday:
week = 7;
break;
case DayOfWeek.Thursday:
week = 4;
break;
case DayOfWeek.Tuesday:
week = 2;
break;
case DayOfWeek.Wednesday:
week = 3;
break;
default:
week = 0;
break;
}
知道今天是星期几了。
例如星期5
int 星期5=5;
int 星期一=1;
5-1=4;
18-4=14;