How to get previous day using datetime

前端 未结 6 1062
日久生厌
日久生厌 2020-12-30 01:40

I want to set a DateTime property to previous day at 00:00:00. I don\'t know why DateTime.AddDays(-1) isn\'t working. Or why DateTime.AddTicks(-1) isn\'t working. First sho

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 02:01

    // get Lat Day Of Current Month

    DateTime newDate= new DateTime();
    var LastDay2 =  newDate.AddMonths(1);
    var LastDay3 = LastDay2.Day * (-1);
    var d5 = LastDay2.AddDays(LastDay3);
    

提交回复
热议问题