How to get the total number of days in a year from the given date

后端 未结 5 1015
别跟我提以往
别跟我提以往 2021-01-05 00:24

I would like to get the total number of days in a year left from the given date .. Assume if a user gives 04-01-2011(MM-DD-YYYY) I would like to find the remain

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-05 00:46

    should do the trick

    int daysLeft = new DateTime(DateTime.Now.Year, 12, 31).DayOfYear - DateTime.Now.DayOfYear;

提交回复
热议问题