得到本周第一天

/// <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;
        }


星期天为一周第一天

posted @ 2012-06-14 11:22  ForrestWu  阅读(277)  评论(0编辑  收藏  举报