DateTime dt = DateTime.Now; //当前时间 int dayOfWeek = Convert.ToInt32(dt.DayOfWeek.ToString("d")); DateTime weekStart = dt.AddDays(1 - ((dayOfWeek == 0) ? 7 : dayOfWeek)); //本周周一 DateTime weekEnd = weekStart.AddDays(6); //本周周日 DateTime lastWeekStart = weekStart.AddDays(-7); //上周周一 DateTime lastWeekEnd = weekEnd.AddDays(-7); //上周周日
时间: 2025-01-07 12:35:05