得到本周第一天

/// <summary>
        /// 得到本周第一天
        /// </summary>
        /// <param name="datetime"></param>
        /// <returns></returns>
        public string GetWeekFirstDay(DateTime datetime) 
        {
            //星期天为第一天
            int weeknow = Convert.ToInt32(datetime.DayOfWeek) + 1;
            weeknow = weeknow == 0 ? 7 : weeknow;
            int daydiff = (-1) * weeknow + 1;
            //本周第一天
            string FirstDay = datetime.AddDays(daydiff).ToString("yyyy-MM-dd");
            return FirstDay;
        }


星期天为一周第一天

你可能感兴趣的:(得到本周第一天)