Getting first and last day of the current month

前端 未结 6 1137
独厮守ぢ
独厮守ぢ 2020-12-13 06:15

I have here 2 datepicker for start date and end date.

how can I get the first day and last day of the current month



        
6条回答
  •  再見小時候
    2020-12-13 06:28

    var myDate = DateTime.Now;
    var startOfMonth = new DateTime(myDate.Year, myDate.Month, 1);
    var endOfMonth = startOfMonth.AddMonths(1).AddDays(-1);
    

    That should give you what you need.

提交回复
热议问题