首页 > 代码库 > 项目的尾声。暑假要开始小论文了,太迟了

项目的尾声。暑假要开始小论文了,太迟了


 

怎样取得本月的第一天以及最后一天。方法有以下几种:

1.     DateTime FirstDay = new DateTime(DateTime.Now.Year,DateTime.Now.Month,1);       

        DateTime LastDay = new DateTime(DateTime.Now.AddMonths(1).Year,DateTime.Now.AddMonths(1).Month,1).AddDays(-1);

2.   DateTime FirstDay = DateTime.Now.AddDays(-DateTime.Now.Day+1);
       
DateTime LastDay = DateTime.Now.AddMonths(1).AddDays(-DateTime.Now.AddMonths(1).Day);